bootstrap-modal
bootstrap-modal copied to clipboard
The loading callback is never called on hide.
Hi, this:
} else if (this.isLoading && this.$loading) {
this.$loading.removeClass('in');
var that = this;
$.support.transition && this.$element.hasClass('fade') ?
this.$loading.one($.support.transition.end, function() { that.removeLoading() }) :
that.removeLoading();
} else if (callback) {
callback(this.isLoading);
}
should become:
} else if (this.isLoading && this.$loading) {
this.$loading.removeClass('in');
var that = this;
$.support.transition && this.$element.hasClass('fade') ?
this.$loading.one($.support.transition.end, function() { that.removeLoading() }) :
that.removeLoading();
if (callback) callback(this.isLoading);
}
Actually, because there is callback = callback || function() {}; you can simply call callback without checking if it exists.
This is what I ended up with:
} else if (this.isLoading && this.$loading) {
this.$loading.removeClass('in');
var that = this;
$.support.transition && this.$element.hasClass('fade') ?
this.$loading.one($.support.transition.end, function() {
that.removeLoading();
callback(that.isLoading);
}) : that.removeLoading() && callback(that.isLoading);
}
Good catch, It probably should be called with removeLoading so that the callback is fired after animation (just as with show).
Something like:
removeLoading: function (cb) {
this.$loading.remove();
this.$loading = null;
this.isLoading = false;
cb(that.isLoading);
}
...
$.support.transition && this.$element.hasClass('fade') ?
this.$loading.one($.support.transition.end, function() { that.removeLoading(cb) }) :
that.removeLoading(cb);
I'd gladly accept a PR if you're interested in making one.
Hi, would it be easier for you to simply apply these few lines? I really have no time to work on this right now. Otherwise I can do it tomorrow. Please choose either way that works for you, thank you.
Doesn't matter to me, I like to leave the project open for contributions where I can. I'll leave this open and get to it next time I'm in the code if I don't get a PR.
Thanks