2 Cancel buttons in Xeditable angular directive
I am using xeditable angular directive. Could you please tell me how to use the 2 undo buttons? B'cos I need to implement 2 functions on it. I mean cancel + my work 1
and cancel + my work 2
. Thanks in advance.
Html
<form editable-form name="tableform" onaftersave="saveTable()" oncancel="cancel()">
//UI code here
<button type="button" ng-disabled="tableform.$waiting" ng-click="tableform.$cancel()" class="btn btn-default">Cancel</button>
</form>
Js
// cancel all changes
$scope.cancel = function() {
};
source to share
You can have two cancel buttons on a form and submit the form as an attribute. Then, in the appropriate undo functions, you can call the form. $ Undo and then execute your logic. form.$cancel
does the same job as calling ng-click="tableform.$cancel()"
.
Play with him: Plunker
//html
<button type="button" ng-disabled="tableform.$waiting" ng-click="cancel1(tableform)" class="btn btn-default">cancel 1</button>
<button type="button" ng-disabled="tableform.$waiting" ng-click="cancel2(tableform)" class="btn btn-default">cancel 2</button>
//controller
$scope.cancel1 = function(tableForm) {
// Call tableForm cancel to reset
tableForm.$cancel();
//Logic1
};
$scope.cancel2 = function(tableForm) {
// Call tableForm cancel to reset
tableForm.$cancel();
//Logic2
};
source to share
You should actually be able to control how the undo button functions. If you read the code carefully, you can see that they just create a few buttons and show or hide them on the current state of the form (form. $ Visible)
Do something like this.
<button type="button" ng-disabled="tableform.$waiting" ng-click="tableform.$cancel()" class="btn btn-default">cancel1</button>
</div>
Here's an example
source to share