In New modal, Create button and hitting Enter behave very differently
In New modal, Create button and hitting Enter behave very differently
Link to test case:
https://live.datatables.net/clone/7829/edit?html,css,js,console,output
Description of problem:
I want to keep the editor open after submit, so the user can enter multiple records in rapid succession. For speed and ease of use, they should be able to use the Enter key to submit a new record.
I followed the example at https://live.datatables.net/hasuqubo/15/edit and adapted it to handle Create instead of Edit.
I create three records with names aaaaaaaaa, bbbbbbbbbb, and cccccccccc.
If I hit the Create button to submit records, it works as expected:
"open"
"preSubmit aaaaaaaaa"
"submitComplete"
"open"
"preSubmit bbbbbbbbb"
"submitComplete"
"open"
"preSubmit ccccccccc"
"submitComplete"
"open"
But if I hit the Enter key to submit records, it submits an ever-larger number of records, some with no data:
"open"
"preSubmit aaaaaaaaa"
"submitComplete"
"open"
"preSubmit bbbbbbbbb"
"submitComplete"
"open"
"preSubmit "
"submitComplete"
"open"
"preSubmit cccccccccc"
"submitComplete"
"open"
"preSubmit "
"submitComplete"
"open"
"preSubmit "
"submitComplete"
"open"
"preSubmit "
"submitComplete"
"open"
While this still "works" in the minimal example, it breaks things in my real app (I have a lot of validation and customization). Why does Enter make the bad submissions, and how can I make it do what the Create button does?
Answers
My issue was that I was re-opening the modal in submitComplete, like the example at https://live.datatables.net/hasuqubo/15/edit. If I do it in submitSuccess instead, it works properly.
Ah glad you resolved it, thanks for reporting back,
Colin