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" >&times; </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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -