File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments