Is it possible to re-submit a form, while having "closeOnComplete" set to false?
Is it possible to re-submit a form, while having "closeOnComplete" set to false?
aop@mhcg.dk
Posts: 15Questions: 4Answers: 0
Hi,
I am wondering if it is possible to re-submit a form (on enter press) while having "closeOnComplete" set to false?
Scenario: Edit row -> change a field -> press enter -> form is submitted -> change another field -> press enter -> submit again.
editor = new $.fn.dataTable.Editor({
ajax: "/add_n_edit",
table: "#table",
fields: fields,
formOptions: {
main: {
onEsc: 'none',
submitOnReturn: true,
closeOnComplete: false
}
});
Tanks in advance.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
What you would need to do is trigger an edit on the same row again. The reason being is that the form has finished its edit so it has effectively been cleared and ready for the next edit.
You could use the
submitComplete
event to trigger the next edit.Regards,
Allan
...
...
As in you can't give it focus at all? That sounds very odd indeed! Are you able to give me a link to the page so I can try it out?
Thanks,
Allan
Hi allan,
No, i CAN give it focus, but only after the focus has been removed when submitting.. So i have to click twice on another input field to gain focus.
Sadly i'm not able to give you a link. I'm not even able to make a fiddle. Sorry.
Hopefully you can help me anyways. :-)
Hi,
It looks like you've removed your previous posts and I can't remember all of the details in them.
Can you show me the code that you are using please?
Allan
Hi Allan,
My question is: When i do as you suggested, use the submitComplete event to trigger the next edit, FOCUS is lost from what ever i was doing. I.e. If i was editing in a textfield and it submits and reopens for a new submit, focus is lost and i have to click on that textfield again to resume typing. It seems like initializing a new edit removes focus from everything... Is there a way to avoid losing focus?
NB: I am submitting the form every time a user stops typing for more than 1-2 seconds, therefore i need to reenable submitting.
Thanks in advance.
I've just tried to reproduce the issue using this example. I used the following code which you can run from your browser's console:
The setTimeout is just so you can click in the document to give it focus, rather than having the focus in the console!
When I submit the row, it immediately then triggers an edit on the same row again and focus is retained.
Are you able to modify that, or give me a link to your page showing the issue, so I can debug the problem please.
Allan
..
Fixed it. I set a timeout after submitcomplete focusing the field.
Thanks
Here is a modification to my code that uses the
preSubmit
event to store the element that has focus when the submit action is activated. That is then used to give it focus again insubmitComplete
:Allan