Update button not firing with extend: 'savedStates'
Update button not firing with extend: 'savedStates'
Hi Allan.
First, thanks for answering my question last Friday, datatables is amazing.
My question has to do with the savedStates. I am using functionality to save a state in the menu which lets the user name the state, then it calls the backend ajax script ss.php to save it to the database. After this happens, it shows in the menu, with an arrow on the right, that then gives 3 options to manipulate that particular saved state (update/rename/remove). My issue is that the "update" button is no longer firing my backend ss.php ajax script. I can see this by inspecting and going to the network tab, and also by monitoring input to the ss.php script. What's weird, is that it was working fine on Friday. Today, the only way to get it to fire is if I save a new state, and then immediately hit "update" without changing any criteria, but if I change anything in the criteria, it will not fire.
Here is a link to test case: https://www.mystockdata.com/dividend-search/
Its a demo app so it will not hurt anything to add/remove saved states.
You can add a "Saved Query" and then go back and try to update it, and the ajax ss.php script never gets called. Any idea what might be going on? The rename and remove buttons work just fine and will always post data to the server. I've also tried from multiple browsers and had a co-worker try from a different location all with the same behavior. Thanks in advance.
-Jason
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Answers
I can confirm this behaviour with a different setup using Python / Flask on the backend.
The only time I can get a AJAX POST to the server for an 'update' action on a state is immediately after creating.
Once a state is the result of loading from the backed as opposed to on-page creation the update action fails to fire hence upates to the state are lost upon a page reload.
Hi,
I missed this at the time - sorry! @jfixsen Could you possibly update the page to use the non-minified version of DataTables and StateRestore so I can debug what is happening there please?
Or @rmd Perhaps you could link to your page with non-minified code?
I've just tried experimenting a bit and it appears to be working in this example so I'm not sure what is going wrong yet I'm afraid.
Allan
Hi Allan,
I can confirm this behavior on your example. Here are the steps to take:
I have similar question open with Colin from a few days ago. I suspect all of these issues are related. Perhaps, the issue is the order in which the ajax-loaded data is recognized by the
stateRestore
function?Any thoughts? I'm sorry for bringing up similar issues in different threads.
Thanks,
Tanner
Hi,
I ran into the same issue. It took me a while to figure out what was going on. It seems that stateRestore considers all states loaded with the ajax function as predefined searches. They don't get updated for this reason. See source file starting on line 762.
You can patch it by adding this in your datatable parameters:
Hope this helps!