How to save edit form without closing it
You can do it by adding a button that will save the record without closing the edit form.
Below are examples for synchronous and asynchronous cases.
function on_edit_form_created(item) {
var save_btn = item.add_edit_button('Save and continue');
save_btn.click(function() {
if (item.is_changing()) {
item.post();
try {
item.apply();
}
catch (e) {
item.alert_error(error);
}
item.edit();
}
});
}
function on_edit_form_created(item) {
var save_btn = item.add_edit_button('Save and continue');
save_btn.click(function() {
if (item.is_changing()) {
item.disable_edit_form();
item.post();
item.apply(function(error){
if (error) {
item.alert_error(error);
}
item.edit();
item.enable_edit_form();
});
}
});
}
With the confirmation alert:
function on_edit_form_created(item) {
var save_btn = item.add_edit_button('Save and continue');
save_btn.click(function() { ask(item) });
}
function ask(item) {
item.question('Save record?',
function() {
if (item.is_changing()) {
item.disable_edit_form();
item.post();
item.apply(function(error){
if (error) {
item.alert_error(error);
}
item.warning('Success save!');
item.edit();
item.enable_edit_form();
});
}
});
}