Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › dev question › Reply To: dev question
November 19, 2021 at 2:00 pm
#35645
Keymaster
Once again, if I am not able to see how this is implemented, at least the search and the results list, I am not able to help.
I understand your “developer” tries everything via jQuery, but we are using native javascript handlers to handle the clicks. jQuery can handle some cases, but everything depends on how and where the icon is placed exactly.
If the jQuery dynamic event handler can not handle this, he should have tried native mutation observers maybe:
var observer = new MutationObserver(function(){
document.querySelectorAll('.asp_r .item .fa-heart').forEach(function(el){
el.addEventListener('click', function(e){
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
console.log('click');
});
});
});
document.querySelectorAll('.asp_r').forEach(function(parent){
observer.observe(parent, { attributes: false, childList: true, subtree: true });
});
..or there is also an event triggered whenever the results are displayed, he can use that as well to attach the event listeners:
jQuery('.asp_m').on('asp_results_show', function(){
jQuery('.fa-heart').off('click').on('click', function(e){
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
console.log('click');
});
});