Last Updated: February 25, 2016
·
551
· mejarc

Adding option to already initiated Bootstrap plugin

  • Access the plugin object that was attached to the element, with .data([plugin name]):

    var myLastMinuteChange = $('.multi-step-nav').data(['bootstrapWizard']);

  • Set options on the plugin object:

    myLastMinuteChange.options.onNext = function(){
     ...
     };

Discover the plugin name with this:

console.log($('.multi-step-nav').data());

2 Responses
Add your response

Very clever, thanks! This has already helped with the carousel plugin. I was looking for a way to easily read and store the value of initiated options, and your solution was perfect:

var interval = $('.carousel').data('carousel').options.interval;

over 1 year ago ·

data() is also a great way to find out what convenience methods are available to a particular plugin. Thanks again!

over 1 year ago ·