powmedia / backbone.bootstrap-modal

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

Bootstrap modal "shown" event not working when "animate" property is set to "false" #57

Open titaniumteeth opened 10 years ago

titaniumteeth commented 10 years ago

If I set animate: true, then shown event is working just fine.

Issue demo: http://jsfiddle.net/nzLSA/40/

betaprior commented 10 years ago

I can confirm this.

DavsX commented 10 years ago

Confirming as well.

marcovc commented 9 years ago

+1

dieselmachine commented 6 years ago

The 'shown.bs.modal' event is triggered by

$el.modal({
        keyboard: this.options.allowCancel,
        backdrop: this.options.allowCancel ? true : 'static'
      });

The event binding follows immediately after, so the event listener doesn't exist when the event is triggered.

It appears that in the master branch, the code now looks like this:

$el.modal(_.extend({
        keyboard: this.options.allowCancel,
        backdrop: this.options.allowCancel ? true : 'static'
      }, this.options.modalOptions));

So in theory (i havent tested this yet) you could add 'show': false to the options and have it create but not display the modal, then the event listener would be added, then you could show the modal at your leisure and the event should be handled.