The minute I first saw Twitter’s Bootstrap I knew I was going to use it continuously. Either for prototyping or building a site in a short period of time, Twitter Bootstrap has an incredible amount of features/plugins that will ensure your website/app will look great under any browser/device.
However, after using some of the Javascript plugins, I notice some of them don’t have a callback function, which is pretty handy when you want to do more custom stuffs. Luckily, after doing some research I found out that in Javascript a callback function can be added through the function property “prototype”.
So imagine you want to do something after a popover is opened. To add a callback function do the following. Notice that you can call it whatever you want:
$.fn.popover.Constructor.prototype.show = function () {
pt.call(this);
if (this.options.afterShowed) {
this.options.afterShowed();
}
}
Once you have done that, you can call the callback function when initialising your popover object:
afterShowed: function() {
// do something
}
});
Look at the demo here.
