I have a form that has a delete button, I would like to create a confirmation box that pop ups when the delete button is clicked. The delete button currently works. I have tried several things in javascript with no luck. I am using Angular.
Is this best approach for this?
Also, does anyone know of any examples for this, I have not found any that work.
$(document).ready(function(){
$("form").validate();
$(".radius small success button").ConfirmDialog('Are you sure?');
});
This is how we're handling our 'confirmation dialogs' (using bootstrap)
The Markup
Setting model to false on controller load to hide by default with
ng-show
On click on event for show popup, calls a function/passes model in
In the controller:
And per the anchors in the html above, can either close the popup or run the function
Place Delete option on the right hand side of each record and on clicking the delete option the record should get deleted from the details and JSON array.
Here's another approach at this. Basically it's a directive that gets the warning string you want to show, and the function to call if the user accepts. Usage example:
Seems like an AngularJS directive is a bit over-the-top for a solution to this. Seems easier just to use straight javascript unless you need some custom functionality to your "confirm()" function.
Hope this helps, cheers