stateRestore not properly creating more than 1 state
stateRestore not properly creating more than 1 state
![trongart](https://secure.gravatar.com/avatar/6b77a334ac77d866ec4703a82b5e8f4f/?default=https%3A%2F%2Fvanillicon.com%2F6b77a334ac77d866ec4703a82b5e8f4f_200.png&rating=g&size=120)
I have a very strange issue with stateRestore:
In my project, I am using stateRestore with Ajax source and the Ajax function as described here. The table and states data are stored on a database and are loaded and saved via php. This all works fine.
However, if a new state is created via the State Save buttons collection and previous states are present, The "Create New State" dialog does not close. It gives the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'node')
which is caused by that._collectionRebuild();
on line 1042 of stateRestore.js
Strangely, the state is still correctly saved in the database for me and is present in the Saved States button collection if I just click on X to manually exit the dialog after I click on Create.
If it is the very first state and no other states are present, everything works fine.
I created an analog test case with the datatables example data here: live.datatables.net/rowavere/1/edit
Once loaded, click on Delete All and create the first state. This will work, and then create a second state and the "Create New State" dialog won't close. If you close it manually, the new state will still be there in the buttons collection.
What do you think is wrong here?
Answers
Figured out that this issue was caused by
splitSecondaries
. Changed the empty button''
to'updateState'
and all works now: live.datatables.net/rebucuka/1/edit