bootstrap-modal icon indicating copy to clipboard operation
bootstrap-modal copied to clipboard

The loading callback is never called on hide.

Open heaven opened this issue 12 years ago • 5 comments
trafficstars

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);
}

heaven avatar Aug 12 '13 20:08 heaven

Actually, because there is callback = callback || function() {}; you can simply call callback without checking if it exists.

heaven avatar Aug 12 '13 20:08 heaven

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);
}

heaven avatar Aug 12 '13 20:08 heaven

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.

jschr avatar Aug 12 '13 20:08 jschr

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.

heaven avatar Aug 12 '13 20:08 heaven

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

jschr avatar Aug 12 '13 20:08 jschr