Search code examples
javascriptangularjsx-editable

Assign Custom Function on Cancel Button Angular X-editable


Is this possible? I have a code that looks like this:

<div class="popover-wrapper"> <a class="glyphicon glyphicon-time" ng-if="activity.type === 'continuous'" ng-style=" { 'border': 'none', 'color': activity.timer.color.icon, 'cursor': 'pointer'}" editable-select="manualTimer.status" e-ng-options="s.value as s.text for s in manualTimerStatuses" onaftersave="timerSet()"></a> </div>

The popover shows up with two buttons. The submit one changes the model, manualTimer.status. However, I am wondering if it is possible to assign a custom function to execute when the cancel button is clicked.


Solution

  • Follow angular-xeditable document in here

    Try to add oncancel attribute with your custom function. It will be trigger when you click Cancel button.

    <div class="popover-wrapper">
        <a class="glyphicon glyphicon-time" oncancel="yourfunction" ng-if="activity.type === 'continuous'" ng-style=" { 'border': 'none', 'color': activity.timer.color.icon, 'cursor': 'pointer'}" editable-select="manualTimer.status" e-ng-options="s.value as s.text for s in manualTimerStatuses" onaftersave="timerSet()" ></a>
     </div>