Search code examples
ajaxinfinite-scrolljquery-ias

How can I reinitialize or destroy `infiniteajaxscroll` V3?


How can I reinitialize IAS or destroy on V3? (no jquery, I am using import InfiniteAjaxScroll from '@webcreate/infinite-ajax-scroll';)

There's also no reinitialize or destroy on their doc (https://docs.v3.infiniteajaxscroll.com/reference/methods)

Infinite Ajax Scroll version: 3
Browser version: FF Dev 71.0b5 (64-bit)
Operating System: OS Catalina (10.15.1)

Solution

  • You can call unbind to remove all event listeners. This should be enough to "destroy" IAS.

    Otherwise you can probably overwrite the variable that contains the IAS instance.

    Pseudo code example:

    // previous instance
    var ias = InfiniteAjaxScroll(/* options */);
    
    // destroy
    ias = null
    
    // reinitialize
    ias = InfiniteAjaxScroll(/* some other options */);