mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Sortable: replaced hard-coded sortable with this.widgetName, and removed lines from destroy that are handled by super. Fixes #7741 - ui.sortable is not working when it is extended
This commit is contained in:
parent
cf3e655be1
commit
228b1b191b
19
ui/jquery.ui.sortable.js
vendored
19
ui/jquery.ui.sortable.js
vendored
@ -63,13 +63,11 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
destroy: function() {
|
||||
this.element
|
||||
.removeClass("ui-sortable ui-sortable-disabled")
|
||||
.removeData("sortable")
|
||||
.unbind(".sortable");
|
||||
.removeClass("ui-sortable ui-sortable-disabled");
|
||||
this._mouseDestroy();
|
||||
|
||||
for ( var i = this.items.length - 1; i >= 0; i-- )
|
||||
this.items[i].item.removeData("sortable-item");
|
||||
this.items[i].item.removeData(this.widgetName + "-item");
|
||||
|
||||
return this;
|
||||
},
|
||||
@ -86,6 +84,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
},
|
||||
|
||||
_mouseCapture: function(event, overrideHandle) {
|
||||
var that = this;
|
||||
|
||||
if (this.reverting) {
|
||||
return false;
|
||||
@ -98,12 +97,12 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
//Find out if the clicked node (or one of its parents) is a actual item in this.items
|
||||
var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
|
||||
if($.data(this, 'sortable-item') == self) {
|
||||
if($.data(this, that.widgetName + '-item') == self) {
|
||||
currentItem = $(this);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
|
||||
if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
|
||||
|
||||
if(!currentItem) return false;
|
||||
if(this.options.handle && !overrideHandle) {
|
||||
@ -528,7 +527,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
for (var i = connectWith.length - 1; i >= 0; i--){
|
||||
var cur = $(connectWith[i]);
|
||||
for (var j = cur.length - 1; j >= 0; j--){
|
||||
var inst = $.data(cur[j], 'sortable');
|
||||
var inst = $.data(cur[j], this.widgetName);
|
||||
if(inst && inst != this && !inst.options.disabled) {
|
||||
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
|
||||
}
|
||||
@ -550,7 +549,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
|
||||
_removeCurrentsFromItems: function() {
|
||||
|
||||
var list = this.currentItem.find(":data(sortable-item)");
|
||||
var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
|
||||
|
||||
for (var i=0; i < this.items.length; i++) {
|
||||
|
||||
@ -576,7 +575,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
for (var i = connectWith.length - 1; i >= 0; i--){
|
||||
var cur = $(connectWith[i]);
|
||||
for (var j = cur.length - 1; j >= 0; j--){
|
||||
var inst = $.data(cur[j], 'sortable');
|
||||
var inst = $.data(cur[j], this.widgetName);
|
||||
if(inst && inst != this && !inst.options.disabled) {
|
||||
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
|
||||
this.containers.push(inst);
|
||||
@ -592,7 +591,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
||||
for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
|
||||
var item = $(_queries[j]);
|
||||
|
||||
item.data('sortable-item', targetData); // Data for target checking (mouse manager)
|
||||
item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
|
||||
|
||||
items.push({
|
||||
item: item,
|
||||
|
Loading…
Reference in New Issue
Block a user