Hello,
I'm using Backbone with Interact.js and I need to send additional data to the dropzone. For example: I'm dragging one Backbone.View onto another and I want the dropzone View to know which View was dropped on it. Right now, all the dropzone gets is the DOM element.
Is there a way to attach additional data when the drag event starts and have this data go to the drop event?
Thank you in advance!
(Great job, BTW, on this awesome library).
There's no built-in way to do this. What I would do instead is make a way to get the Views from the event.target and event.relatedTarget properties of the drag/drop events. For example, storing the View object in el._view or setting the IDs of the elements to those of the Models they represent or something. Then you could easily get the additional data from the drag/drop events.
Thanks for your response. I ended up doing something similar to what you suggested, I think. I wrote:
event.interactable.model = self.model; This way, I can get the model when the object is dropped on the dropzone.
Thanks!
You're welcome!
Just in case someone else wants to solve that problem, here with some more words:
In the draggables start function do something like
…
onstart:function(event){
event.interactable.model = "bla";
},
…
and in the droppable you can then do something like
…
ondrop: function (event) {
console.log(event.draggable.model);
},
…
Most helpful comment
Just in case someone else wants to solve that problem, here with some more words:
In the draggables start function do something like
and in the droppable you can then do something like