Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added relocate event. #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ Also, the default list type is `<ol>`.
Similarly to <code>toArray</code>, it accepts <b>attribute</b> and <b>expression</b> options.</dd>
</dl>

## Events

<dl>
<dt>change</dt>
<dd>Fires when the item is dragged to a new location. This triggers for each location it is dragged into not just the ending location.
<dt>sort</dt>
<dd>Fires when the item is dragged.</dd>
<dt>revert</dt>
<dd>Fires once the object has moved if the new location is invalid.</dd>
<dt>relocate</dt>
<dd>Only fires once when the item is done bing moved at its final location.</dd>
</dl>

## Known Bugs

*nestedSortable* doesn't work properly with connected draggables, because of the way Draggable simulates Sortable `mouseStart` and `mouseStop` events. This bug might or might not be fixed some time in the future (it's not specific to this plugin).
Expand Down
13 changes: 10 additions & 3 deletions jquery.mjs.nestedSortable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* jQuery UI Nested Sortable
* v 1.3.5 / 21 jun 2012
* http://mjsarfatti.com/code/nestedSortable
* v 1.3.6 / 21 jun 2012
* https://github.com/mjsarfatti/nestedSortable
*
* Depends on:
* jquery.ui.sortable.js 1.8+
Expand Down Expand Up @@ -237,7 +237,14 @@
}

$.ui.sortable.prototype._mouseStop.apply(this, arguments);


var pid = $(this.domPosition.parent).parent().attr("id");
var sort = this.domPosition.prev ? $(this.domPosition.prev).next().index() : 0;

if(!(pid == this._uiHash().item.parent().parent().attr("id") &&
sort == this._uiHash().item.index())) {
this._trigger("relocate", event, this._uiHash());
}
},

serialize: function(options) {
Expand Down