Is there a global object that Bootstrap creates when initializing one of its components, e.g. Tabs? How does it work?
Using Bootstrap 3.2.
First they define
var Tab = function (element) { this.element = $(element) } Then they go further and prototype Tab:
Tab.prototype.activate = function (element, container, callback) { var $active = container.find('> .active') var transition = callback //... } And finally they add Tab as a jQuery method using their Plugin factory:
function Plugin(option) { return this.each(function () { var $this = $(this) var data = $this.data('bs.tab') if (!data) $this.data('bs.tab', (data = new Tab(this))) if (typeof option == 'string') data[option]() }) } $.fn.tab = Plugin $.fn.tab.Constructor = Tab Plugin seems to be something like the jQuery UI Plugin Factory, so you call $("#a").tab("method") and the Plugin object will call the corresponding method on a Tab object.
Plugin is used to insatiate the object that really handles the calls to the jQuery plugin, it's a bit like a bridge. It's similar to this: learn.jquery.com/jquery-ui/widget-factory
$.fn.tabs = ...Is that the answer to your question?