Skip to content

Commit

Permalink
move 'shown' and 'hidden' listeners before modal is created - fix pow…
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanebachelier committed Sep 11, 2012
1 parent fd2f4e6 commit 37e10d5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/backbone.bootstrap-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,24 @@
var self = this,
$el = this.$el;

//Focus OK button - called when modal shown
$el.one('shown', function() {
$el.find('.btn.ok').focus();
self.trigger('shown');
});

// listener for hidden
$el.one('hidden', function() {
self.remove();
self.trigger('hidden');
});

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

//Focus OK button
$el.one('shown', function() {
$el.find('.btn.ok').focus();

self.trigger('shown');
});

//Adjust the modal and backdrop z-index; for dealing with multiple modals
var numModals = Modal.count,
Expand Down Expand Up @@ -194,12 +200,6 @@

$el.modal('hide');

$el.one('hidden', function() {
self.remove();

self.trigger('hidden');
});

Modal.count--;
},

Expand Down

0 comments on commit 37e10d5

Please sign in to comment.