How to reinitialise plugin if DOM changes?
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?
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
I have the same issue. Do you know how to solve it? Thanks
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.
@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 …