JQUERY-UI Draggable with asynchronous selectors

2019-08-28 03:15发布

问题:

Is it possible to use JQUERY-UI draggable with elements that are imported asynchronously using jquery's .load function? I guess that I would need to use .on or .bind, but can't figure out something that works...

回答1:

I would just use the .load callback to assign the draggable property:

$("#containerselector").load('path', function () {
    $(this).find( "elementsthatshouldbedraggableselector" ).draggable();
});