javascript - Loading popover content with ajax not working properly -
i using ajax call display show method content different products in popovers in page.
i use following code:
function details_in_popup(link, div_id){     $.ajax({         url: link,         success: function(response){             $('#'+div_id).html(response);         }     });     return '<div id="'+ div_id +'">loading...</div>'; }  $(function () {   $('[data-toggle="popover"]').popover({     "html": true,     "title": '<span class="text-info"><strong>title</strong></span>'+             '<button type="button" id="close" class="close" >× </button>',     "content": function(){         var div_id =  "tmp-id-" + $.now();         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');   });  }); });   the problem encountering first time open popover, content filled properly, second time, title duplicates in popover, third time, content first popover , second 1 mixed up.
it's if previous popovers never cleaned-up , accumulated each time open new popover...
is there obvious in code might creating problem ?
thanks!
reset div on ajax success 
$('#'+div_id).text('');   than append response.
Comments
Post a Comment