awkward / backbone.modal

A plugin for Backbone.js that simplifies creating modals for your application.
http://awkward.github.io/backbone.modal/
Other
362 stars 71 forks source link

marionette behaviors #88

Open linus-amg opened 8 years ago

linus-amg commented 8 years ago

hey, first off.. we use backbone.modal really a lot, its so easy and has so much awesomeness, we build everything with marionette, so we are using the marionette region version of backbone.modal, I would like to know if anybody of the contributors sees an easy way to have marionette behaviors possible to define inside a new modal view, i saw that the Backbone.Modal https://github.com/awkward/backbone.modal/blob/master/src/backbone.modal.coffee#L10 extends from Backbone.View, i tried to extend from Marionette.ItemView and Marionette.LayoutView but could not make it work. any ideas?

linus-amg commented 8 years ago

it would also be convenienent to have the marionette modelEvents, collectionEvents etc.

linus-amg commented 8 years ago

i dont call for any change, since its a Backbone Plugin, i'm rather looking for advice to customize Backbone.Modal to accept Marionette.View instead of Backbone.View

jeff-h commented 8 years ago

The project website talks about usage within Marionette, which to me implies that when using Marionette it would extend Marionette's view rather than Backbone's view. So I guess contrary to @elgubenis comment above, I do humbly ask for a change :)

Perhaps provide an optional Marionette.Modal object (which is otherwise identical, except that it extends Marionette's itemView) if Marionette is found? This would introduce no breaking changes or anything but would allow us to use all the usual Marionette goodness in our Modal views :)

Thanks again for the awesome plugin.

emudojo commented 8 years ago

I guess I'm in the same boat, I was thinking on Creating a VIewCollection, but it won't work due to the hardcoded backbone.view dependency

jimf commented 6 years ago

FWIW, I'm not thrilled with the fact that this plugin directly extends from Backbone.View. For the reasons cited here, it just makes things difficult when you need functionality from specialized Backbone views. I'm a fan of a mixin pattern that adds functionality into an existing, arbitrary instance:

const MyView = SomeArbitraryBackboneView.extend({
    initialize() {
        // Add methods/properties for modal behavior:
        Backbone.Modal.mixin(this);
    }
    // ...
});

I'd have to think some more about the specifics (for example, how dealing with naming conflicts should work), but my gut tells me such an approach should work and doesn't necessitate breaking changes.