Skip to content

Commit de1d540

Browse files
author
Paul Bakaus
committed
sortable: don't copy content from the original item into the placeholder anymore by default (fixes #3595), check if event still exists in _trigger, fixes issue when you call $(this).sortable('cancel') from within a callback
1 parent 142fddb commit de1d540

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

ui/ui.sortable.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,19 +556,18 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
556556
.addClass(className || self.currentItem[0].className+" "+self.options.cssNamespace+"-sortable-placeholder")
557557
.removeClass(self.options.cssNamespace+'-sortable-helper')[0];
558558

559-
if(!className) {
559+
if(!className)
560560
el.style.visibility = "hidden";
561-
document.body.appendChild(el);
562-
// Name attributes are removed, otherwice causes elements to be unchecked
563-
// Expando attributes also have to be removed because of stupid IE (no condition, doesn't hurt in other browsers)
564-
el.innerHTML = self.currentItem[0].innerHTML.replace(/name\=\"[^\"\']+\"/g, '').replace(/jQuery[0-9]+\=\"[^\"\']+\"/g, '');
565-
document.body.removeChild(el);
566-
};
567561

568562
return el;
569563
},
570564
update: function(container, p) {
565+
566+
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
567+
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
571568
if(className && !o.forcePlaceholderSize) return;
569+
570+
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
572571
if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
573572
if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
574573
}
@@ -896,7 +895,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
896895
_trigger: function(type, event, inst, noPropagation) {
897896
$.ui.plugin.call(this, type, [event, this._uiHash(inst)]);
898897
if(!noPropagation) $.widget.prototype._trigger.call(this, type, event, this._uiHash(inst));
899-
if(event.returnValue === false) this.cancel();
898+
if(event && event.returnValue === false) this.cancel();
900899
},
901900

902901
plugins: {},

0 commit comments

Comments
 (0)