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());
Written by Melanie Archer
Related protips
2 Responses
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Twitter bootstrap
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#