Skip to content Skip to sidebar Skip to footer

Using Bootstrap Popover Callback

I'm currently using bootstrap popovers to add some additional fields to my form. To format my select boxes, I need to take advantage of the popover callback, however I seem to be

Solution 1:

There is no popover option showCallback instead try using one of Bootstraps built in popover events

So for example triggering the alert when the popover is shown you would do this

$("[data-toggle=popover]").on('shown.bs.popover', function () {
    alert('called back');
});

I updated your JS Fiddle for an example...

Solution 2:

Try this: I have added a callback function by using prototype of jquery.

var tmp = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function () {
  tmp.call(this);
  if (this.options.callback) {
    this.options.callback();
  }
}

this.$("[data-toggle=popover]").popover({
  html: true,
  content: function() {
    return $('#popover-content').html();
  },
  callback: function() {
    alert('called back');
  }
});

Have updated in your fiddle.

Post a Comment for "Using Bootstrap Popover Callback"