Greetings!
I’m synchronizing a form to a list. This list interacts with a server data source.
I believe I’ve set up the list correctly for undoOnError.
webix.protoUI(
{
name: 'undo_list'
}, webix.Undo, webix.ui.list)
{
view: 'undo_list',
id: 'user_admin_list',
select: true,
url: '/api/users',
undo: true,
save: {
url: 'json->/api/users',
updateFromResponse: true,
undoOnError: true
}
}
$$('the_form').bind($$('user_admin_list'))
Later, for a validated form …
$$('the_form').save()
When I save the form, the form data will update the list (synchronize to the list) even when a server error occurs when saving the form (i.e. 409 error).
To clarify: the $$(‘the_form’).save() works as expected when there are no errors. The list and the data source are properly updated. The question only concerns errors encountered during the save.
However, when I use a separate form to add to the same list, the undo does work if a server error is encountered.
var vv = $$('add_form').getValues()
$$('user_admin_list').add(vv)
// if a server error occurs, the item is removed from the list by undo
Right now my only workaround is to manually restore the data by intercepting onAfterSaveError or by chaining server validation calls before calling save() on the form.
Can you help point out a more elegant approach?
Best Regards,
Bruce