I was reading a blog post by Derek Bailey where he talks about managing twitter bootstrap modals in Marionette. That gave me an idea to write a javascript mixin that I could reuse for my twitter bootstrap modals that just simply lets me open and close modals properly. It helps eliminate a little bit of boiler plate code to handle modals.
You can see the code at https://github.com/kdocki/marionette-twitter-bootstrap-modal-mixin
You can see a demo at http://kdocki.github.io/marionette-twitter-bootstrap-modal-mixin
I could have stuck to single inheritance by extending a Marionette.ItemView or something. But what if you wanted to use a Marionette.CompositeView? You’d end up writing the same class twice, so by using the mixin you are able to ‘mix in’ only the functionality needed for the modal.
** Update ** After talking to Brian Mann about it, he suggested I use a Marionette.Region to do modals which is how I do modals now. I might do another post on this later.