-
-
Save asafge/7430497 to your computer and use it in GitHub Desktop.
/** | |
* 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); | |
} | |
}); | |
} | |
} | |
}]); |
so easy & so awesome! thank you so much!
+1 Thank you!
Thanks. Very straight forward and useful.
it's really helpful!
Clean and simple. Thanks.
This is great and easy to use. Thanks!
Looks good but, i dont know why but my confirm action is called twice (so http ajax) loading the page for two times... is there any reason ?
(script included only once)
áááááh the directive was included for twice time ..sorry ! ;)
Is this available as a module through Bower?
hello, thank it served me.
a query, if confirmed execute an action , but if not confirmed , I just submit the form , I need to do nothing , to if
if ( message && confirm ( message) ) {
$ scope apply ( attrs.ngReallyClick ) . ;
} else {
$ scope apply ( void (0 ) ) . ;
}
I put something, so you do not run nothing but works for me , just send the form where I have incorporated ng - really- click
great job! worked perfectly!
great snippet!
Thanks!
Top! Thank you.
This is so great. Thanks!
Awesome man! 👍
Beginner saved. Tnahk you!
FYI - you don't need to clean this up afterwards w/ $destroy
because the element that has the event listener is already being removed which also kills the bind
(personally though, I would use on
over bind
Hi,
Im using a function just like this but i have an issue as other guys told, everytime l select cancel button the requested post it increments one at time, This way when l finally confirm the modal lt sends all the cumulative requests.
Someone have this issue?
thx
Thankyou! Good Stuff.
Thank you somuch...
nice na !!!
confirm action is called thrice :( and ajax post is called thrice in my case, can someone help?
Thanks
Awesome thank you!