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 reinitialise plugin if DOM changes? #27

Open
christophermiles opened this issue May 25, 2015 · 4 comments
Open

How to reinitialise plugin if DOM changes? #27

christophermiles opened this issue May 25, 2015 · 4 comments

Comments

@christophermiles
Copy link

I note from the source code that the variables lis and len are cached, and the comments in the code suggest reinitialising the plugin if the DOM changes after the plugin is first initialised.

Is there a fork of this code which doesn't cache those variables?

Alternatively, how can I reinitialise the plugin if the DOM changes subsequent to the plugin initialising?

@craigivemy
Copy link

Did you ever find a solution to this? I have the same issue. Tabs update the content via ajax, once that has happened the filter no longer works

@jrioromero
Copy link

I have the same issue. Do you know how to solve it? Thanks

@donShakespeare
Copy link

Put your initial filter init code in a function. Run this function whenever you need it.
E.g. I have an image gallery of 4000 images. If I delete 2500 images at once, or add another 3000, the function is ran in my delete callback.

Also using jQuery UI draggable, I run the function when an element s dropped in another div.

function runMyAwesomeFilter() {
        // Activate fastLiveFilter w/ callback
        var numDisplayed = $(".num_displayed");
        $("#filter_input").fastLiveFilter("#list_to_filter", {
            callback: function (total) {
                numDisplayed.html(addCommas(total));
                //do more stuff
                //do more stuff
                //do more stuff
            },
        });
    }

call this whenever you need it runMyAwesomeFilter(); at startup, after DOM change, etc.

@ghost
Copy link

ghost commented May 30, 2018

@donShakespeare i think the problem in your solution is that all elements are cached each time you call that function. So if you call that function multiple times the overall javascript performance will drop depending on how many elements there are and how often the function was called …

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

4 participants