How to keep editing window open
How to keep editing window open
Hello,
Is there any way, using primary editing method (with big pop-up window), to add additional execute button that will do the same as the existing submit button but that will not close the pop-up window it self? - so I will be able to instantly add another record.
The button it self isn't a problem:
$('#myTable').DataTable( {
buttons: [
{
extend: 'create',
editor: myEditor,
formButtons: [
{
label: 'Accept',
fn: function () { this.submit(); }
},
'Save and close'
]
}
]
} );
But how to change the action that it will not close the window? - submit() is closing.
2nd question is it possible to pass directly data between form instance fields (other way than by session variables)? For example:
I've got form with 2 fields:
1) Option (dropdown)
2) Input
Iam filling them with data.
After pressing "Accept" button I wish to send the data to a database and also forward Option selection to a new form instance without closing the edit window.
Is it posiible? If not maybe is it possible to automatically reopen the edit window? - only after proper validation and db submission
This question has accepted answers - jump to:
Answers
You can use the
formOptions.main
option to set thecomplete
option tonone
. That will keep the Editor window open after submission and you would need to callclose()
to close it.Allan
Allan thank You,
It is almost doing what I want.
I have added this code:
and - as You said - during submission window does not close.
The problem is that I cant submit the next data.
When I am clicking the button nothing happens.
To make it work I have to close the window and reopen it again - any suggestions?
Ok,
I have figured out it by my self.
The solution was to call create():
Now I have a problem how to stop next step after the submit() if there are some errors from validator?
Since submit 1st parameter calls a function during the success callback my idea was to:
but it does not work...
Another try was using submitSuccess
Now it works but when I will for instance submit 3 times with "Accept" and then 1 time with "Save and close" something strange happens with interface (I've got blur without edit window)
One thing about this:
That will execute the
create
immediately after submit is called - and since the submit is async, that will be before the data has been returned from the server.Perhaps what you want is:
And likewise for the close option.
I'm not sure I've quite understood the issue / goal correctly, but I think that will resolve the issue.
Allan
Ok now it works, but TBH I don't know why...
In my code (look above) I was using very similar:
Why
var that = this;
done the job?Regardless of that, thank You!
Here you are executing
this.create()
and then passing the result intothis.submit()
which you don't want! You wantthis.create()
to execute after the submit function is done which is why you pass it in as a function - thesubmit
function knows what to do with it.Allan
You are right :) Thank You