jquery - Bootstrap popover on moving elements -
i trying use static popover on element position may change accordion. popover stays @ same place when accordion activated. how can enable popover change position accordingly ?
here related code:
(on jsfiddle: http://jsfiddle.net/gordianknot/vlmnm/1/ may click section instance)
html:
<h3><a href="#">section 1</a></h3> <div><p>section 1 content</p></div> <h3><a href="#">section 2</a></h3> <div><p>section 2 content</p></div> </div> <br/> <a id="example" name="example" href="#" class="btn btn-danger">example button</a>
js:
$(function() { $("#accordion").accordion({ collapsible: true, autoheight: false, active: false }); $("#example").popover({ trigger:'manual', placement: 'right', html: 'true', title : 'test', content : 'hello !', }); $('#example').popover('show'); });
perhaps it's not elegant solution, do:
jquery:
var hasmoved = false; $('#accordion').click(function () { if ($('#accordion').children('h3').hasclass('ui-state-active')) { if(!hasmoved) { $('.popover').animate({ top: "+=60" }, 250); hasmoved = true; } } else { $('.popover').animate({ top: "-=60" } , 250); hasmoved = false; } }); });
Comments
Post a Comment