-
Notifications
You must be signed in to change notification settings - Fork 896
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
reIndex() on filtered list only indexes visible items and not the original list #410
Comments
This seems to be a duplicate of #388. This problem make it nearly impossible to use filter or search with a list that can be modified with ajax code. A possible solution to this issue would be to modify reIndex to:
I'm not sure if there would be side effects regarding If it can help someone, for now my less than satisfacting workaround is to:
|
This is how I am handling updating list.js when I have an AJAX action button. I have stripped the code down and changed some things to be a better example but the idea is you should have the "element" that is either your "list item" or a child of one. From there you can do a find on the "list" items to get the List's item.obj and update the values with the new ones.
|
If you use ajax and want to reindex, you can do it to retrieve everything after the ajax call : |
I've just submitted a pull request with an alternative approach to solving this problem: This adds a refresh() method which rescans all existing items (including hidden ones) from their corresponding HTML elements. This means that hidden items are not removed from the list. It also means that any new rows are not added, but I've also provided an addItem() method for doing this explicitly. |
Use case:
Everything would work correctly if the list is not being searched. If the list is being searched, calling reIndex() on the searched list will only grab the visible ones and it stops working properly.
I'm on listjs 1.1.1
The text was updated successfully, but these errors were encountered: