Skip to content

Commit eff807f

Browse files
authored
Merge pull request #2 from Pita/master
Prevent multiple loadings of same modal
2 parents 9033def + 845e103 commit eff807f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

jquery.modal.js

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
};
3131

3232
$.modal = function(el, options) {
33+
if (el.data('is-loading') === 'true') {
34+
return;
35+
}
3336
var remove, target;
3437
this.$body = $('body');
3538
this.options = $.extend({}, $.modal.defaults, options);
@@ -50,12 +53,14 @@
5053
this.open();
5154
//AJAX
5255
} else {
56+
el.data('is-loading', 'true');
5357
this.$elm = $('<div>');
5458
this.$body.append(this.$elm);
5559
remove = function(event, modal) { modal.elm.remove(); };
5660
this.showSpinner();
5761
el.trigger($.modal.AJAX_SEND);
5862
$.get(target).done(function(html) {
63+
el.data('is-loading', null);
5964
if (!$.modal.isActive()) return;
6065
el.trigger($.modal.AJAX_SUCCESS);
6166
var current = getCurrent();

0 commit comments

Comments
 (0)