a5hik / ng-sortable

AngularJS Library for Drag and Drop, supports Sortable and Draggable. Supports Touch devices.

Home Page:http://a5hik.github.io/ng-sortable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

give dragStart callback the ability to disable dragging

mzealey opened this issue · comments

I would like the ability to return a value from a callback saying whether it is ok to drag this element or not, rather than having to manually set the no-drag attribute which is slower and doesn't currently work dynamically. Basically I'm cloning from one list to another, but if the item already exists in the second list I don't want the drag to be able to start from the first. I restrict it at present by setting accept function in the second list, but it would be much nicer to be able to restrict dragging from the first list dynamically (ie perform the logic when the drag is attempted to be started). I would think the nicest way from an API point of view would be to look at the return value from dragStart and allow a false value to cancel the drag operation.

I think u already have the answers for ur scenario.. handle this in the dragStart callback.