how set default value manually in twitter bootstrap 2 , twitter bootstrap 3?
i have following code, can see same properties in options being used on again (i have overwrite them because required different defaults).
the 3 properties used on again trigger
placement
& html
.
how can override default options set twitter bootstrap in javascript?
javascript (on dom ready)
$('.pop1').popover({ trigger: 'hover', placement : 'right', html: true, // used once (and 2 above) title : 'my title popover1', content : 'my content popover1' }); $('.pop2').popover({ trigger: 'hover', //used again placement : 'right', html: true, title : 'my title popover2', content : 'my content popover2' }); $('.pop3').popover({ trigger: 'hover', //and again! placement : 'right', html: true, title : 'my title popover3', content : 'my content popover3' });
html:
<span class="pop1"><i class="icon-info-sign"></i></span> <span class="pop2"><i class="icon-info-sign"></i></span> <span class="pop3"><i class="icon-info-sign"></i></span>
i wanted jquery validators (& other plugins): jquery.validator.setdefaults()
so basically, how can set bootstrap default values twitter bootstrap 2 , twitter bootstrap 3?, bootstrap uses custom default values don't have override them on , on again throughout code, how can customize default value 1 specified me , not twitter bootstrap 2 or twitter bootstrap 3.
bootstrap v2 - view jsfiddle
you can log defaults
see defaults set bootstrap 2 using:
console.log($.fn.popover.defaults); // log default values console
you can override defaults set twitter bootstrap 2 using following:
// make sure jquery loaded before trying override defaults! $.fn.popover.defaults.trigger = 'hover'; // set default trigger hover $.fn.popover.defaults.placement = 'right'; // set default placement right $.fn.popover.defaults.html = true; // set default html (parse html) true
bootstrap v3 - view jsfiddle
you can log defaults
see defaults set bootstrap 3 using:
console.log($.fn.popover.constructor.defaults); // log default values console
you can override defaults set twitter bootstrap 3 using following:
// make sure jquery loaded before trying override defaults! $.fn.popover.constructor.defaults.trigger = 'hover'; // set default trigger hover $.fn.popover.constructor.defaults.placement = 'right'; // set default placement right $.fn.popover.constructor.defaults.html = true; // set default html (parse html) true
default values
by default values set following (they same in boostrap 2 & 3):
animation: true container: false content: "" delay: 0 html: false placement: "right" selector: false template: "<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>" title: "" trigger: "hover"
Comments
Post a Comment