I am using the jQuery UI Draggable/Sortable demo (http://jqueryui.com/demos/draggable/#sortable) for the basis of my project. I need to get a reference to the
If you don't fear accessing the Sortable
's internal state, you can do the following:
$('#sortable').sortable({
receive: function() {
// Sortable.currentItem refers to the item just added.
// jQuery UI < 1.10 uses "sortable" as its data key,
// jQuery UI >= 1.10 defines an "instance" method to get the current instance.
var $item =
(
$('#sortable').data('sortable') || // jQuery UI < 1.10
$('#sortable').sortable('instance') // jQuery UI >= 1.10
).currentItem;
}
);
Fiddle: http://jsfiddle.net/t33bt/12/
Keep in mind though, that this might not work in a future jQuery UI version anymore because it doesn't use the official API. But nonetheless it works even in jQuery UI 1.11 (current version as of time of this writing).