ng-inline-edit icon indicating copy to clipboard operation
ng-inline-edit copied to clipboard

Callback is fired before update of model

Open borystomala opened this issue 9 years ago • 10 comments

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

borystomala avatar Dec 11 '15 13:12 borystomala

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..)

tameraydin avatar Dec 11 '15 13:12 tameraydin

@borystomala @tameraydin were you able to make a workaround for this problem?

divyekhanna avatar Feb 15 '16 10:02 divyekhanna

@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 avatar Feb 15 '16 10:02 tameraydin

@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!

divyekhanna avatar Feb 15 '16 11:02 divyekhanna

Same issue.

suavelizard avatar Mar 10 '16 07:03 suavelizard

+1

dominickolbe avatar Apr 15 '16 11:04 dominickolbe

+1... i'm using with angularfire.. this use case is very common

cubissimo avatar Apr 25 '16 19:04 cubissimo

+1 ... @tameraydin can you please show me where in the file I can edit to resolve this issue?

melliott03 avatar May 22 '16 11:05 melliott03

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;
    });
}

kjen93 avatar Jul 14 '16 12:07 kjen93

+1. At least we should have something to tell outside when the model has been updated. Need a ng-change here.

duongkame avatar Sep 13 '16 02:09 duongkame