javascript - How to make sure only one popover is activated at each time -
i have following code shows ajax content each element page.
function details_in_popup(link, div_id){ $.ajax({ url: link, success: function(response){ $('#'+div_id).empty().html(response); } }); return '<div id="'+ div_id +'">loading...</div>'; } $(function () { $('[data-toggle="popover"]').popover({ "html": true, "title": '<span class="text-info"><strong>quick view</strong></span>' + '<button type="button" id="close" class="close" >×</button>', "content": function () { var div_id = $(this).data('id'); return details_in_popup($(this).data('url'), div_id); } }).on('shown.bs.popover', function (e) { var popover = jquery(this); $('body').on('click', '.close', function (e) { //popover.popover('hide'); $(".popover").remove(); $(this).data('id').remove(); }); }); });
and in html have :
<button data-url="<%= my_url %>" href="#" type="button" class="" data-container="body" data-toggle="popover" data-id="<%= product.slug %>" style="">popover</button>
this code trick , shows popover correct content, in sense first time popover opens. have normal behavour
but starting second time, have 2 popovers 1 on top of other, 1 loading message, , other content. button of loading popover 1 can close both popovers.
first time popover:
second time popover:
do have idea on how ride of second loading popover , bind close button the popover have content ?
thank , hope clear in explanation
i tried html code. think need add data content well. data-content="your text here". rest seems fine. , close functionality add data-trigger = "focus". click here http://www.bootply.com/zkpqgsakbq
if need close button here example. might figure out. [][1]
[1]: http://jsfiddle.net/erik1337/fve22/
Comments
Post a Comment