how to add item and notify item double-click of jquery sortable?
-
i'll make my web page to just like desktop of windows. there are small icons, and they can move by user drag, as you know. so, i plan to use jquery ui, http://jqueryui.com/demos/sortable/display-grid.html[^]. i wonder how to add item dynamically, and notify item double-click. help.
-
i'll make my web page to just like desktop of windows. there are small icons, and they can move by user drag, as you know. so, i plan to use jquery ui, http://jqueryui.com/demos/sortable/display-grid.html[^]. i wonder how to add item dynamically, and notify item double-click. help.
To add items dynamically, it looks like you would have to add another DOM element and then call the sortable initializer on the entire set of elements again. So you may have a button that adds a dom element to a div container with the id 'sortable'. Then call the method below.
$( "#sortable" ).sortable();
For the double click functionality, I would use jQuery's dblclick API. So while you're creating the DOM element above, right before you call sortable(), I would attach a double click handler like so:
$('#target').dblclick(function() {
alert('Handler for .dblclick() called.');
}); -
To add items dynamically, it looks like you would have to add another DOM element and then call the sortable initializer on the entire set of elements again. So you may have a button that adds a dom element to a div container with the id 'sortable'. Then call the method below.
$( "#sortable" ).sortable();
For the double click functionality, I would use jQuery's dblclick API. So while you're creating the DOM element above, right before you call sortable(), I would attach a double click handler like so:
$('#target').dblclick(function() {
alert('Handler for .dblclick() called.');
}); -
Thanks for that, I've never used that functionality before.