Skip to content

Instantly share code, notes, and snippets.

@mfrancois
Created November 29, 2013 17:54
Show Gist options
  • Select an option

  • Save mfrancois/7709526 to your computer and use it in GitHub Desktop.

Select an option

Save mfrancois/7709526 to your computer and use it in GitHub Desktop.
Angular directive for adding jConfirm into element
angular.directive('ngConfirmClick', [
function () {
return {
priority: 100,
restrict: 'A',
link: function (scope, element, attrs) {
element.bind('click', function (e) {
var message = attrs.ngConfirmClick;
var title = attrs.title;
var link = attrs.href;
e.stopImmediatePropagation();
e.preventDefault();
jConfirm(message, title, function (r) {
if (r !== false) {
window.location.href = link;
}
return false;
});
});
}
};
}
]);
<ul>
<li class="iDialog">
<a href="#" ng-confirm-click="{{langue['wCertification:action:sendtouser:message']}}" title="{{langue['wCertification:action:sendtouser:title']}}">
<span>{{langue['wCertification:action:sendtouser:button']}}</span>
</a>
</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment