Skip to content

Commit 1d32675

Browse files
authored
Merge pull request #514 from Patternslib/chrome-modal-fix-2
Chrome modal fix 2
2 parents c33ce88 + ae4ac36 commit 1d32675

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pat/modal/modal.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ define([
8181

8282
_init_handlers: function() {
8383
var $el = this.$el;
84-
$(document).on("click.pat-modal", ".close-panel", this.destroy.bind(this));
84+
$(document).on("click.pat-modal", ".close-panel[type!=submit]", this.destroy.bind(this));
85+
$(document).on("click.pat-modal", ".close-panel[type=submit]", this.destroy_inject.bind(this));
8586
$(document).on("keyup.pat-modal", this._onKeyUp.bind(this));
8687
if (this.options.closing.indexOf("outside")!==-1) {
8788
$(document).on("click.pat-modal", this._onPossibleOutsideClick.bind(this));
@@ -148,6 +149,13 @@ define([
148149
}
149150
},
150151
destroy: function() {
152+
var $el = this.$el;
153+
// if working without injection, destroy right away.
154+
$(document).off(".pat-modal");
155+
$el.remove();
156+
$('body').removeClass("modal-active");
157+
},
158+
destroy_inject: function() {
151159
var $el = this.$el;
152160
if ($el.find('form').hasClass('pat-inject') ) {
153161
// if pat-inject in modal form, listen to patterns-inject-triggered and destroy first

0 commit comments

Comments
 (0)