admin管理员组

文章数量:1300013

Does anyone know in which order the jQuery sortable events are being triggered? I'm asking this because I had a problem with stop and update. It made more sense to me that update event would e after stop event but that was not the case.

Is this documented anywhere or did someone investigate this? I couldn't manage to find a proper list and I don't feel like looking through the code just yet.

Does anyone know in which order the jQuery sortable events are being triggered? I'm asking this because I had a problem with stop and update. It made more sense to me that update event would e after stop event but that was not the case.

Is this documented anywhere or did someone investigate this? I couldn't manage to find a proper list and I don't feel like looking through the code just yet.

Share Improve this question asked Nov 29, 2013 at 8:51 OktavOktav 2,1512 gold badges22 silver badges33 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 8

The order of events is:

create - Triggered when the sortable is created

start - Triggered when sorting starts

activate - Triggered for every connected list on drag start

over - Triggered when a sortable item is moved into a sortable list

sort - Triggered during sorting

change - Triggered during sorting, but only when DOM position has changed

beforeStop - Triggered before sorting stops, placeholder/helper

update - Triggered when stopped sorting and DOM position has changed

deactivate - Triggered before sorting stopped, propagated to all possible connected lists

out - Triggered when a sortable item is moved away from a sortable list

stop - Triggered when sorting has stopped

There are other events which can occur too:

receive/remove - Triggered when items are moved between lists

No idea why this isn't clearer on the jQueryUI site.

Note that, depending upon the event triggered, the ui arguments differs. It's worth looking at the API documentation to be clear what this is and to debug it.

http://api.jqueryui./sortable/

The stop event is the last to be fired. Check here to see all the events of a Jquery sortable element.

From the current source code, update events are put into a queue:

delayedTriggers.push(function(event) {
    this._trigger("update", event, this._uiHash());
}); //Trigger update callback if the DOM position has changed

The queued events are then triggered between beforestop and stop:

this._trigger("beforeStop", event, this._uiHash());
for (i=0; i < delayedTriggers.length; i++) {
        delayedTriggers[i].call(this, event);
} //Trigger all delayed events
this._trigger("stop", event, this._uiHash());

Therefore, in the current implementation, update events will always be triggered before stop events.

本文标签: javascriptjQuery UI Sortable order of eventsStack Overflow