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
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.
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.