powmedia / backbone.bootstrap-modal

Bootstrap Modal wrapper for use with Backbone.
MIT License
183 stars 97 forks source link

Make content views aware of modals #5

Closed jeffutter closed 12 years ago

jeffutter commented 12 years ago

First off, thanks for this project. I had a rather hackish way of doing bootstrap modals with my backbone-forms but this is much more elegant.

In my case it would be useful to make the views aware of their modal My views have functions that save/validate them and it makes more sense to me to have things like:

modal.on('ok', () function{ if (! @noteFormView.submit()) { modal.preventClose(); } }

in the model instead of outside. This is particularly obvious when using a bunch of views that inherit from the same base class (and the bass class manages the saving). It would be much more DRY - to me - to handle the 'ok' click in the base model rather than outside of the views all together.

powmedia commented 12 years ago

I don't think that would belong in the main bootstrap modal library but you can probably create a wrapper function to keep things DRY; I've done a similar thing in my app where I instantiate and validate the modal in a helper function