Skip to content

Instantly share code, notes, and snippets.

@asafge
Created November 12, 2013 13:06
Show Gist options
  • Save asafge/7430497 to your computer and use it in GitHub Desktop.
Save asafge/7430497 to your computer and use it in GitHub Desktop.
ng-really? An AngularJS directive that creates a confirmation dialog for an action.
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
if (message && confirm(message)) {
scope.$apply(attrs.ngReallyClick);
}
});
}
}
}]);
@pragyeshthakur
Copy link

Thank you somuch...

@prashantbiradar92
Copy link

nice na !!!

@muthubonzi
Copy link

confirm action is called thrice :( and ajax post is called thrice in my case, can someone help?

@dimaanj
Copy link

dimaanj commented Sep 9, 2019

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment