Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Sortable: replaced hard-coded sortable with this.widgetName, and remo…
…ved lines from destroy that are handled by super. Fixes #7741 - ui.sortable is not working when it is extended

(cherry picked from commit 228b1b1)
  • Loading branch information
rdworth committed Sep 27, 2011
1 parent 872387a commit 5c6cfe2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions ui/jquery.ui.sortable.js
Expand Up @@ -62,13 +62,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;
},
Expand All @@ -86,6 +84,7 @@ $.widget("ui.sortable", $.ui.mouse, {
},

_mouseCapture: function(event, overrideHandle) {
var that = this;

if (this.reverting) {
return false;
Expand All @@ -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) {
Expand Down Expand Up @@ -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]);
}
Expand All @@ -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++) {

Expand All @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit 5c6cfe2

Please sign in to comment.