Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Scroll to top when clicking on the navigation links
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 6 years, 2 months ago.
- AuthorPosts
- February 21, 2018 at 10:54 am #16870
Hi there,
I’m trying to add a scroll effect. I have isotopic results and navigation active. It looks like in the screenshot. if I click on a page it should scroll up.
I tried this:
jQuery(document).ready(function( $ ) { $('.asp_navigation li').on('click', function () { $('html, body').animate({ scrollTop: $('.asp_shortcodes_container').offset().top }, 300, 'linear'); }); });
But without effect. It doesn’t even add event listeners.
Can you tell me if this is possible and if I’m missing an easy click in the plugin settings?Best regards,
SimonAttachments:
You must be logged in to view attached files.February 21, 2018 at 11:20 am #16872Hi Simon,
Your code looks okay, but I would recommend a slightly different approach. If the event handler does not attach, the code might not be positioned correctly – or the event handler gets detached, as the results are dynamically changing.
I would suggest something like this:
Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
This appears to be working on my end. The jQuery ‘on’ handler is better attached to the results div, as the results content is constantly changing, and the handler can get detached on dynamically changing elements.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 21, 2018 at 11:44 am #16873Hi there,
thank you, that works exactly as needed!
Best regards,
SimonFebruary 21, 2018 at 11:45 am #16874You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.