From 552df22e1c6cc52c6809f5ce458d3a46dc6aa3fa Mon Sep 17 00:00:00 2001 From: Philip Manavopoulos Date: Tue, 9 Oct 2012 12:24:12 +0200 Subject: [PATCH] Allow for an optional drag handle to be specified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When defining the gridster, you can now define a draggable.handle selector: For example:     $("#widgets").gridster({         widget_margins: [10, 10],         widget_base_dimensions: [565, 400], draggable: { stop: function(event, ui) { console.log('save new columns'); }, handle: '.title' }     }); If handle is omitted (or left blank), it works as it did previously. If a value is specified, then dragging only starts if the element which was clicked matches the selector specified. Added by @vieron: Closes #29 --- src/jquery.draggable.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/jquery.draggable.js b/src/jquery.draggable.js index 14a074936a..90c1d05ab2 100644 --- a/src/jquery.draggable.js +++ b/src/jquery.draggable.js @@ -14,7 +14,8 @@ limit: true, offset_left: 0, autoscroll: true, - ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'] + ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'], + handle: null // ,drag: function(e){}, // start : function(e, ui){}, // stop : function(e){} @@ -329,6 +330,10 @@ }; fn.ignore_drag = function(event) { + if (this.options.handle) { + return !$(event.target).is(this.options.handle); + } + return $.inArray(event.target.nodeName, this.options.ignore_dragging) >= 0; };