Skip to content

Commit 3a2e1f0

Browse files
committed
Add nmDestroy function and all needed destroy function in filters fix #136
1 parent d5da144 commit 3a2e1f0

5 files changed

+32
-0
lines changed

js/jquery.nyroModal.filters.form.js

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jQuery(function($, undefined) {
4444
});
4545

4646
$.ajax(ajax);
47+
},
48+
destroy: function(nm) {
49+
nm.opener.off('submit.nyroModal');
4750
}
4851
}
4952
});

js/jquery.nyroModal.filters.formFile.js

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ jQuery(function($, undefined) {
103103
nm.store.formFileIframe = undefined;
104104
delete(nm.store.formFileIframe);
105105
}
106+
},
107+
destroy: function(nm) {
108+
nm.opener.off('submit.nyroModal')
106109
}
107110
}
108111
});

js/jquery.nyroModal.filters.iframeForm.js

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jQuery(function($, undefined) {
5656
nm.store.iframeFormIframe = undefined;
5757
delete(nm.store.iframeFormIframe);
5858
}
59+
},
60+
destroy: function(nm) {
61+
nm.opener.off('submit.nyroModal')
5962
}
6063
}
6164
});

js/jquery.nyroModal.filters.link.js

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jQuery(function($, undefined) {
3535
}
3636
});
3737
$.ajax(ajax);
38+
},
39+
destroy: function(nm) {
40+
nm.opener.off('click.nyroModal');
3841
}
3942
}
4043
});

js/jquery.nyroModal.js

+20
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ jQuery(function($, undefined) {
226226
});
227227
});
228228
},
229+
230+
// Public function for destroying a nyroModal instance, only for non open modal
231+
destroy: function() {
232+
if (this._open)
233+
return false;
234+
this._callFilters('destroy');
235+
if (this.elts.all)
236+
this.elts.all.remove();
237+
return true;
238+
},
229239

230240
// Init HTML elements
231241
_initElts: function() {
@@ -553,6 +563,15 @@ jQuery(function($, undefined) {
553563
: $.extend(true, {opener: me}, _nmObj, opts));
554564
});
555565
},
566+
nmDestroy: function() {
567+
return this.each(function() {
568+
var me = $(this);
569+
if (me.data('nmObj')) {
570+
if (me.data('nmObj').destroy())
571+
me.removeData('nmObj');
572+
}
573+
});
574+
},
556575
nmCall: function() {
557576
return this.trigger('nyroModal');
558577
},
@@ -847,6 +866,7 @@ jQuery(function($, undefined) {
847866
nm: _internal.nyroModal,
848867
nyroModal: _internal.nyroModal,
849868
nmInit: _internal.nmInit,
869+
nmDestroy: _internal.nmDestroy,
850870
nmCall: _internal.nmCall
851871
});
852872

0 commit comments

Comments
 (0)