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 to reset? #745

Open
Eikosa opened this issue Apr 14, 2022 · 4 comments
Open

How to reset? #745

Eikosa opened this issue Apr 14, 2022 · 4 comments

Comments

@Eikosa
Copy link

Eikosa commented Apr 14, 2022

How can I update it in list.js after the table's content has changed with normal javascript? otherwise the previous list is coming back

@lwmirkk
Copy link

lwmirkk commented May 3, 2022

Use:
.reIndex()

https://listjs.com/api/#reindex

@vanboom
Copy link

vanboom commented Oct 5, 2023

Note reIndex() builds from the visible HTML so if the list is currently filtered, the new index will only include the visible items. Not sure if this is the intended behavior...looking for a method to reIndex the full set while retaining the filter.

@lwmirkk
Copy link

lwmirkk commented Oct 5, 2023

Today I use in this way to re-index a list with items changed in "search in progress / filtered" as example:
Filter the list as usual.
When filter / search items in the list, I set a variable to search_in_progress = true.
when remove an item with searchin progress / filter in progress:
I clear the search, remove this item, reIndex and set the search / filter to the desired value again.
This happens so fast the user not see the list update when clearing the filter / search, and the item is removed in the original desired position.

@vanboom
Copy link

vanboom commented Oct 5, 2023

@lwmirkk - yes, great idea. I was attempting to do this but had one logic twist that your suggestion helped to clarify. The list filter must be cleared prior to changing the DOM, then you can reindex and re-filter. It works - thank you!

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

3 participants