From f9c8e85b092217eaea5079cb34de2f56a10b525f Mon Sep 17 00:00:00 2001 From: bistoco Date: Sat, 3 Nov 2012 01:46:01 -0200 Subject: [PATCH] Update jquery.sortable.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added option for placeholder - added custom markup for placeholder as option, useful when using with tables. Example : // JS CODE $('table.data tbody').sortable( {   items: 'tr' , placeholder : ' ' }) ; // CSS STYLE FOR TR > TD .sortable-placeholder td { background:#FFFEB8; height:100px; width:100%; } --- jquery.sortable.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jquery.sortable.js b/jquery.sortable.js index 350d172..3fa3019 100644 --- a/jquery.sortable.js +++ b/jquery.sortable.js @@ -10,7 +10,8 @@ var dragging, placeholders = $(); $.fn.sortable = function(options) { var method = String(options); options = $.extend({ - connectWith: false + connectWith: false , + placeholder: null }, options); return this.each(function() { if (/^enable|disable|destroy$/.test(method)) { @@ -22,7 +23,9 @@ $.fn.sortable = function(options) { return; } var isHandle, index, items = $(this).children(options.items); - var placeholder = $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="sortable-placeholder">'); + var placeholder = ( options.placeholder == null ) + ? $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="sortable-placeholder">') + : $( options.placeholder ).addClass('sortable-placeholder'); items.find(options.handle).mousedown(function() { isHandle = true; }).mouseup(function() {