Interact.js: Sending meta data to drropzone

Created on 24 Sep 2015  Â·  4Comments  Â·  Source: taye/interact.js

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).

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

… 
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);
},
…

All 4 comments

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);
},
…
Was this page helpful?
0 / 5 - 0 ratings

Related issues

freefalling picture freefalling  Â·  3Comments

rbozan picture rbozan  Â·  9Comments

jbaartman picture jbaartman  Â·  4Comments

kongaraju picture kongaraju  Â·  6Comments

jf-m picture jf-m  Â·  6Comments