Search code examples
angularjsx-editable

Angular X-Editable - additional parameters to onbeforesave


I am using angular-xeditable to edit a table value inline and want to save that value in the database once the input is blurred. What I want to do is call the save function using the "onbeforesave" attribute.

The problem is the function takes only the changed value as parameter. I also need the id of the tag on which xeditable is applied.

So how can I pass a reference to the DOM element (best option) or just the element id (will suffice in this case).

Many thanks!


Solution

  • on your ng-repeat on front end, on your "onBeforeSave" attribute you can pass the $index so it will be like onBeforesave="myFUnction($index)" and then use the index in targeting the element of array to alter values. so if your front end ng-repeat uses $scope.items, you will use the index to target $scope.items[index] and then you can take all the data on this index and pass data to server to do some database updates.