Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ajax functunality doesn't work when search bar appears inside a popup
- This topic has 11 replies, 2 voices, and was last updated 4 years, 10 months ago by
Ernest Marcinko.
-
AuthorPosts
-
August 4, 2021 at 5:53 am #34151
Aramis197793
ParticipantPlease go to this link:
https://www.francophilesanonymes.com/registration/Scroll down and you’ll see a green “Test” button
Click on the button and a pop up will appear.
Inside the popup, you’ll see a search bar. If you try to search for something you’ll see that the AJAX functionality doesn’t work (i.e. it doesn’t try to “guess” what you’re looking for).
Can you please review and advise? Also please provide me your support email so I could provide you with access to my site.
Thanks in advance,
ZviAugust 4, 2021 at 9:40 am #34158Ernest Marcinko
KeymasterHi,
I see an error message in the console, giving an issue with an undefined jQuery script.
Can you please try changing the compatibility options to this. It should very likely resolve the problem.
August 4, 2021 at 9:53 am #34159Aramis197793
ParticipantIt works. Thanks 🙂
August 4, 2021 at 11:05 am #34161Aramis197793
ParticipantSorry, I was happy to early. 🙂
Please go to my site (https://www.francophilesanonymes.com/) in mobile. You’ll see a red looking glass. Click on it and try looking for something. The ajax doesn’t seem to work. However, if you go to the desktop version and try using the search bar in the header the ajax will work.
Zvi
August 4, 2021 at 3:04 pm #34174Ernest Marcinko
KeymasterLooks like there is some sort of an element cloning going on there. It is a very bad practice, and causes nothing but issues. It is a shame to see it is caused by Elementor.
You can try this custom code to get by it:
add_action('wp_footer', 'wp_footer_asp_try_fix_init', 9999); function wp_footer_asp_try_fix_init() { ?> <script> (function($){ $('[class*=-search]').on('click', function(){ setTimeout(function(){ $('.hasAsp').removeClass('hasAsp'); $('.hasASP').removeClass('hasASP'); ASP.fixClones(); ASP.initialize(); }, 500); }); })(jQuery); </script> <?php }Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
However please keep in mind, that this may not work in all cases, or at all, as the cause of this issue not generated by a bug in our code. Simply the element clone mechanism in javascript is a very nasty solution, and will cause issues with javascript handlers.
August 4, 2021 at 4:08 pm #34175Aramis197793
ParticipantHi Ernest,
Sadly adding the code didn’t work. Is there anything which can be done by Elemntor to resolve this (sorry but I’m not very technical so I have no idea what’s element clone mechanism is and how it works).
Thanks in adavnce,
ZviAugust 4, 2021 at 4:44 pm #34176Aramis197793
ParticipantBTW, I noticed that this issue doesn’t happen in desktop. I brought back the test button in this page and you can see for yourself: https://www.francophilesanonymes.com/registration/
August 5, 2021 at 8:12 am #34178Ernest Marcinko
KeymasterI don’t see the code on the page at the moment, are you sure you added it correctly? When I tested the code via the console, it was working for me almost all the time.
From the elementor perspective, there is unfortuantely nothing to do about it. It is very situational. In many cases it does work, in other cases it does not. We added code to the plugin to try to resolve these clone related conflicts as much as possible, but unfortunately it is very hard to get around them, if even possible.
I will to some more tests on our local servers to maybe add some improvements if possible for the next release, but I don’t know how much room for improvement is in there.
August 5, 2021 at 8:18 am #34179Aramis197793
ParticipantIn the attached screenshot you can see that I’ve added the code to functions.php of my theme. If I made any mistake (perhaps I should use a code snippets plugin), please let me know.
August 5, 2021 at 9:00 am #34182Ernest Marcinko
KeymasterThat seems okay, but the code is not present on the site front-end unfortunately, I can’t see it in the source.
Make sure to clear all layers of cache – page, minify, CDN and everything.
August 5, 2021 at 1:07 pm #34183Aramis197793
ParticipantHi.
I have cleaned all cache. Can you check again?
Zvi
August 5, 2021 at 1:16 pm #34184Ernest Marcinko
KeymasterThe code is still not present in the page source, I double checked. It is not in effect.
-
AuthorPosts
- You must be logged in to reply to this topic.