0

So I did this

$('div#faq_search_result').replaceWith(decodeHtml(data.html_result));

It seems fine but the on click events is not working

this class won't work

dt class= "c-faqList__dt"

Code for the JS

var dfd = new $.Deferred();
var self = this;
self.$elm = elm;

self.$elm.on('click','.c-faqList__dt',function(event){
    $(this).siblings('.c-faqList__dd').slideToggle(100)
});

dfd.resolve();
return dfd.promise();
The Process
  • 5,913
  • 3
  • 30
  • 41
Hitsuzen
  • 3
  • 2

1 Answers1

0

try something like this:

$('div#faq_search_result').parent().on('click','.c-faqList__dt',function(event){
    $(this).siblings('.c-faqList__dd').slideToggle(100)
});

assumption: .c-faqList__dt is inside div#faq_search_result

Shishir Arora
  • 5,521
  • 4
  • 30
  • 35
  • $('div#faq_search_result').replaceWith(decodeHtml(data.html_result)); this will remove children + events attached on them. If you use event delegation and attach event on parent then events will remain attched. – Shishir Arora Apr 05 '16 at 03:12
  • yes with $._data. for more: http://stackoverflow.com/questions/2008592/can-i-find-events-bound-on-an-element-with-jquery – Shishir Arora Apr 06 '16 at 14:08