I want to make a custom element with text taken from the element “being dragged” using a helper function. My problem is that ui is undefined, so I don’t know how to get a hold of the source of the drag.
$('.draggable').draggable({
helper: function(event, ui) {
var foo = $('<span style="white-space:nowrap;">DRAG TEST</span>');
return foo;
}
});
The
helperfunction you’re applying is invoked the following way:That means that
thisrefers to the.draggableyou want inside that function, for example:You can test it out here.