Open piotr-dobrogost opened 6 years ago
Is this what you are looking for?
One way to submit data on server is to define onbeforesave attribute pointing to some method of scope. Useful when you need to send data on server first and only then update local model (e.g. $scope.user). New value can be passed as $data parameter (e.g. <a ... onbeforesave="updateUser($data)">).
No, it's not as there is no way to neither modify model in onbeforesave
(it will be overwritten later with the original $data
by the library) nor to return a value which the model should be set to.
In other words you can pass new value as $data
parameter to onbeforesave
but there is no way to pass modified (final) new value from onbeforesave
to be used later by the library when updating the model. You are forced to make a side note inside onbeforesave
what the new final value should be, return false
and then inside onaftersave
consult the side note you had made and possibly update model yourself accordingly.
Current flow: onbeforesave
(take a side note with the final new value and return false) ➞ the library updates model with the new value (instead of the final new value) ➞ onaftersave
(consult the side note and update model with the final new value yourself)
Desired flow: onbeforesave
(return the final new value) ➞ the library updates model with the final new value
To sum it up, there's no way to update model right from onbeforesave
now.
Pull requests are welcome :)
I can't find example showing how to manually update model in
onbeforesave
/onaftersave
functions.All I managed to find on this subject is the following statement at https://vitalets.github.io/angular-xeditable/#onbeforesave:
It seems like allowing fourth type of return value (
object
?) inonbeforesave
with the final value which the model should be set to would be useful. My need seems similar to what had been requested in x-editable project in issue Update value from validattion at vitalets/x-editable/issues/354.Could you please add example showing this scenario?