Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I reinitialize on V3? #396

Closed
ivanasetiawan opened this issue Nov 10, 2019 · 11 comments
Closed

How can I reinitialize on V3? #396

ivanasetiawan opened this issue Nov 10, 2019 · 11 comments

Comments

@ivanasetiawan
Copy link

Support question

I have been trying to google around but with no succes! there's also no destroy?
How can I reinit IAS on V3? (no jquery, I am using import InfiniteAjaxScroll from '@webcreate/infinite-ajax-scroll';)

  • Infinite Ajax Scroll version: 3
  • Browser version: FF Dev 71.0b5 (64-bit)
  • Operating System: OS Catalina (10.15.1)
@fieg
Copy link
Member

fieg commented Nov 11, 2019

My answer from https://stackoverflow.com/questions/58790605/how-can-i-reinitialize-or-destroy-infiniteajaxscroll-v3:

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 */);

@ivanasetiawan
Copy link
Author

Hi @fieg! Thanks for answering! I tried both unbind and also ias = null but the URL still loading the old state. Case:

  1. load ias page 2 & 3
  2. trigger filtering with select element (AJAX GET on change)
  3. I scroll down and see the old state as if I am scrolling on the old state:
    Start loading http://abc.com:8000/browse/?page=2&1573468431687&page=3&1573468434722&page=4

@fieg
Copy link
Member

fieg commented Nov 11, 2019

Can you check if your pagination links are correct, because this looks strange: ?page=2&1573468431687&page=3&1573468434722&page=4. The page argument is appended, instead of replaced.

@ivanasetiawan
Copy link
Author

ivanasetiawan commented Nov 11, 2019

Hi @fieg! Yea it currently works like that, I previously used the jquery-ias v2.2.3 and it worked perfectly (also with $.ias().reinitialize();) - I just don't get why the URL GET is persistent?

is there a way to fix this? sorry and thank you!

@fieg
Copy link
Member

fieg commented Nov 13, 2019

I didnt see this behavior with other implementations, so I guess it something specifics in yours. Do you have a live url so I can check it out?

@fieg
Copy link
Member

fieg commented Dec 17, 2019

@ivanasetiawan I released a new beta version which fixes an scoping issue. Maybe that caused to old url to persist. Can you try the new version and see if it fixes your problem?

@ivanasetiawan
Copy link
Author

ivanasetiawan commented Dec 17, 2019

@fieg Awesome! I will update and let you know.
Just to be sure, should I implement it with .reinitialize() or unbind or ias = null?

@fieg
Copy link
Member

fieg commented Dec 20, 2019

I think like this:

// previous instance
var ias = InfiniteAjaxScroll(/* options */);

// destroy (not really needed)
ias = null

// reinitialize (creates new instance)
ias = InfiniteAjaxScroll(/* some other options */);

@fieg
Copy link
Member

fieg commented Jan 10, 2020

I’m closing this issue for now. Please let me know if it works as suggested. If it doesn’t you may reopen the issue.

@fieg fieg closed this as completed Jan 10, 2020
@ivanasetiawan
Copy link
Author

@fieg apology for the delay! It seems to be working properly. Thank you!

@fieg
Copy link
Member

fieg commented Jan 10, 2020

Np, glad to hear it's working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants