• Resolved topitoconnectey

    (@topitoconnectey)


    Hi ! Thank you for this great plugin.
    I have a small issue, the smooth scroll is not working on ajax loaded content.
    I assume it is because it’s called on the document ready function ?

    How can I make it work ? ??

    Thank you !

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author malihu

    (@malihu)

    Hi, I can’t really help unless I see your page/site. Can you post your link?

    Thread Starter topitoconnectey

    (@topitoconnectey)

    Of course !
    Here is the relevant page:
    https://dev.lesdeuxvagues.com/abdp/artistes
    Please note that the smooth scroll works perfectly (on the letters) on page load, but when clicking the filters, it doesn’t work anymore !

    Plugin Author malihu

    (@malihu)

    I checked the page. The issue happens because of the way the filter script removes the letter links.

    This is what happens:

    On page load, the letter links have 2 classes added by “Page scroll to id”:
    _mPS2id-h and __mPS2id
    These classes are added automatically by “Page scroll to id” in order to work.

    When you click a filter, the filter script removes the letter links and adds back only the ones that correspond to the filter. The ones that are added back are missing the __mPS2id class, so “Page scroll to id” can no longer work.

    If you manually add back the __mPS2id class on the filtered letter links, it’ll work (I tested this on-the-fly with browser’s dev tools).

    If you can find a way to add back the __mPS2id class on the filtered letter links each time a filter is clicked, the issue will be solved. I can’t really say how to do this but you’d definitely need to modify the filters javascript.

    Hope this helps

    Thread Starter topitoconnectey

    (@topitoconnectey)

    Thank you very much for a quick and useful answer ! ?? I’m adding the class back on AJAX request success.

    Since this class is added automatically by Page Scroll To Id, can I suggest you could plan in a future update to fix it ?
    I assume that by creating a “instanciating” function that adds all relevant classes and so on, and calling that function on document.ready, ajaxComplete, and making it accessible for people to use in other use cases ?

    Plugin Author malihu

    (@malihu)

    The plugin already has an internal “live” function that auto-enables it on elements that are added dynamically.
    The issue here is that the filter script adds back already enabled elements (links that are already enabled by “Page scroll to id”) with the difference that it removes only one essential class (the added-back links already have the other classes, events etc.).

    The ajaxComplete callback needs to be done on the ajax script (it’s not something that can be done within the plugin or be automated). The actual solution is exactly what you did ??

    Thanks a lot for your review ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Smooth scroll not working on ajax loaded content’ is closed to new replies.