I have made a jsFiddle where i use twitter bootstrap toggle buttons & popover.
HTML:
<div class="btn-group btn-toggle">
<button class="btn btn-sm btn-info">On</button>
<button class="btn btn-sm btn-primary active">Off</button>
</div>
<button id="popbutton" class="btn btn-lg btn-warn">pop up</button>
JS:
var popupElement = '<div class="btn-group btn-toggle"><button class="btn btn-sm btn- info">On</button><button class="btn btn-sm btn-primary active">Off</button></div>';
$('#popbutton').popover({
animation: true,
content: popupElement,
html: true
});
$('.btn-toggle').click(function () {
$(this).find('.btn').toggleClass('active');
if ($(this).find('.btn-primary').size() > 0) {
$(this).find('.btn').toggleClass('btn-primary');
}
if ($(this).find('.btn-danger').size() > 0) {
$(this).find('.btn').toggleClass('btn-danger');
}
if ($(this).find('.btn-success').size() > 0) {
$(this).find('.btn').toggleClass('btn-success');
}
if ($(this).find('.btn-info').size() > 0) {
$(this).find('.btn').toggleClass('btn-info');
}
$(this).find('.btn').toggleClass('btn-default');
});
The toggle button works, but when i use the same buttons inside a popover, it won't work.
Please suggest a method.
Uncaught SyntaxError: Unexpected token ;
, though I'm not sure if that is related – Didi