Exec javascript code after filter has been applied

AlexTCGPro

Member
Hey there, I have an ajax list in my frontend, I'm trying to run a simple javascript script that changes the color of the rows of a list depending on its content, I managed to make it work fairly easily just using

Code:
window.addEventListener('load', function () {
//code
})

My code looks at every row, checks one specific value within that row, turns that value into a color and it finally applies the color as style.

The thing is that I just added a dropdown filter and of course, the previos script won't run after the filter has been applied as it just runs after the site loads and not when it's updated.

I tried adding an event listener for the dropdown filter but it isn't working properly, for what I can tell filtering has some steps, first you change the dropdown selection, then the list refreshes with the filter (here is where the loading animations plays) and finally, the list loads with the filter applied. This is what gives me issues, any code I run listening to the dropdown will be undone after the list finishes refreshing, because the new values don't load until the last step.

Do you know which element should I add and event listener to so my custom javascript code runs immediately after the list finishes refreshing and not at the moment of the selection?
I tried adding a timer and it works, but it's not smooth, if I knew exactly what event and element to look after it would be instantaneous.

I tried listening to 'change' on the list and rows themselves but nothing.
 
Have you tried "fabrik.list.loaded" event in list_XX.js?
Thank you for replying. I'm trying it but so far no effect, I'm pointing both to the list and the dropdown filter but to no effect.

Well, I made a list_15.js file in fabrik components using what you said, however 'fabrik.list.loaded' only triggers when the list first load, not when is updated, I tried 'list.filter' as well but it's the same as before, it runs before the lists is fully refreshed.
 
Last edited:
You can also try "fabrik.list.submit.ajax.complete" if you already haven't.

Just guessing as I don't have the time to dig into this more deeply at the moment and do some testing.
 
Last edited:
You can also try "fabrik.list.submit.ajax.complete" if you already haven't.

Just guessing as I don't have the time to dig into this more deeply at the moment and do some testing.
Thank you man! It was that! It's working perfectly now!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top