Skip to content

Instantly share code, notes, and snippets.

@knedle
Created December 14, 2013 23:14
Show Gist options
  • Save knedle/7966286 to your computer and use it in GitHub Desktop.
Save knedle/7966286 to your computer and use it in GitHub Desktop.
JS jQuery - auto .confirm dialog
// <a href="3" class="confirm" data-confirm="Realy detete this item?">Delete Item</a>
$(document).on('click', '.confirm', function() {
var text = '';
if ($(this).attr('data-confirm')) {
text = $(this).attr('data-confirm');
}
if (text.length == 0) {
text = 'Really take this action?';
}
var answer = confirm(text);
return answer;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment