0

I am updating the div content from ajax and use .html element. Content is adding successfully but after adding whole page is stop working means nothing is clickable.

Ajax code

$('body').on('click', '.save-meeting', function() {
   $.easyAjax({
     url: 'url/to/fetch/div',
     container: '#container',
     type: "POST",
     data: $('#container').serialize(),
     success: function(data) {
         $('#div_to_update').html(data.html);
     }
  })
});

The content in data.html is adding in #div_to_update Successfully but after after that nothing is clickable. Can any one guide me what I am missing here?

Noman Shaikh
  • 139
  • 2
  • 14
  • Can you post the complete HTML code? – Vikram Aditya Sep 10 '22 at 16:51
  • which part you want b/c file is too large . and my html is adding sucessfully so I don't think there is any issue with html. – Noman Shaikh Sep 10 '22 at 16:55
  • Does this answer your question? [Attach event to dynamic elements in javascript](https://stackoverflow.com/questions/34896106/attach-event-to-dynamic-elements-in-javascript) – Ivar Sep 10 '22 at 16:56
  • It stops working because you likely have attached event listeners to element within this `div_to_update`. If you set the HTML to that element, you effectively replace everything inside it, and so all of the listeners will be lost. – Ivar Sep 10 '22 at 16:57
  • I have updated question showing how I use listeners. – Noman Shaikh Sep 10 '22 at 17:28

0 Answers0