I need to create items that have drag and drop and sort functionality. So an item can be dragged into another item.
I have seen a few solutions to do drag via a mixin and create a draggable view using this mixin and then creating another view from droppable via the droppable mixin.
But i need each item / view to have draggable, droppable and sortable functionality.
Please can anyone tell me the best way to do this via mixins or subclassing or … ?
Also can i create a jqueryUi mixin as a base mixin and then use that mixin when creating the draggable, droppable and sortable mixins ? is this possible ?
Is it best to use jqueryUI or the html5 drag and drop api or something else ?
Thanks for the help
Rick
Not sure if you saw the code by Katz here, but I’m using this to make a View: Droppable, Draggable, … or any other interaction supported by jQuery UI. So you define a base Mixin, which you will use in all jQuery UI interaction Mixins:
And then define the Draggable Mixin:
the Resizable Mixin:
Basically for each UI interaction you want to define the
uiType(draggable, droppable, sortable, etc.), theuiOptionsof the interaction (observed by the mixin), and theuiEventsof the interaction that you want to implement in your View.By including JQ.Draggable and JQ.Droppable in your View, it automatically becomes draggable and droppable + you are able to change its options in your View and reflect those changes on the UI plugin, e.g.
this.set('delay', 900), and implement the plugin events in your View, e.g.drag: function(){ /* do something when dragging*\ }).