One feature of my Backbone app involves associating models of type A with models of type B, which is done by dragging view A onto view B. In B's view class I listen for the drop event and from this I get the DOM element of view A, but no information about model A.
What's the best way to go about retrieving this information? My best guesses so far are
but all these approaches seem convoluted/inelegant.
Storing as a data-attribute is actually quite clean, and the performance will not be bad. You can store the model's cid
attribute as data-cid
on the DOM el, and use the collection's getByCid
method to retrieve the model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With