Skip to content

Commit

Permalink
Merge pull request #65 from ImLiam/patch-1
Browse files Browse the repository at this point in the history
Add option to disable drag event
  • Loading branch information
RamonSmit authored Jun 16, 2017
2 parents 7c4a787 + 3dccee3 commit 24e7850
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $('.dd').nestable({
});
```

`onDragStart` callback provided as an option is fired when user starts to drag an element.
`onDragStart` callback provided as an option is fired when user starts to drag an element. Returning `false` from this callback will disable the dragging.
```js
$('.dd').nestable({
onDragStart: function(l,e){
Expand Down Expand Up @@ -289,6 +289,10 @@ These advanced config options are also available:

## Change Log

### 16th June 2017

* [imliam] Added support to return `false` from the `onDragStart` event to disable the drag event

### 28th May 2017

* [pjona] Function `add` support `parent_id` property
Expand Down
6 changes: 5 additions & 1 deletion jquery.nestable.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,11 @@
position.top = e.pageY;
position.left = e.pageX;

this.options.onDragStart.call(this, this.el, dragItem, position);
var continueExecution = this.options.onDragStart.call(this, this.el, dragItem, position);

if (typeof continueExecution !== 'undefined' && continueExecution === false) {
return;
}

this.placeEl.css('height', dragItem.height());

Expand Down

0 comments on commit 24e7850

Please sign in to comment.