ng-inline-edit
ng-inline-edit copied to clipboard
Callback is fired before update of model
When callback defined in inline-edit-callback is fired, the value of model is still not updated. In my opinion callback should be fired after model was updated with new value, so operation on model (e.g. persistance to DB) could be performed. Please see plunker: http://plnkr.co/edit/6xAnNkXJ28ZcNNYzWXwh
Yes I agree but after taking a rough look seems that it requires some refactoring which i don't have time for -at least for now-. Feel free to make a PR covered with tests.
(Otherwise I think you already noticed that the first argument in callback function will be the new value..)
@borystomala @tameraydin were you able to make a workaround for this problem?
@divyekhanna so far, no any PRs.. and why exactly you try to use scope value there, but not using the first parameter -which possibly helps you-?
@tameraydin Thanks for the quick reply. I basically have a restangular (REST client) object and I'm editing an attribute using ng-inline-edit. Restangular offers a convenient object.put() method, so i'm using this method just out of convenience.
I'll use the newValue callback param for now. Thanks again!
Same issue.
+1
+1... i'm using with angularfire.. this use case is very common
+1 ... @tameraydin can you please show me where in the file I can edit to resolve this issue?
You can fix this bug by replacing
function _onSuccess() {
$scope.model = inputValue;
$scope.callback({
newValue: inputValue
});
$scope.editMode = false;
}
by
function _onSuccess() {
$scope.model = inputValue;
$timeout(function() {
$scope.callback({
newValue: inputValue
});
$scope.editMode = false;
});
}
+1. At least we should have something to tell outside when the model has been updated. Need a ng-change here.