Skip to content

Instantly share code, notes, and snippets.

@hiraq
Created September 23, 2015 06:14
Show Gist options
  • Save hiraq/733c543dbab7e46ec81d to your computer and use it in GitHub Desktop.
Save hiraq/733c543dbab7e46ec81d to your computer and use it in GitHub Desktop.
simple jquery plugin for window confirm
'use strict';
(function($) {
$.fn.confirmit = function(msg, successFunc) {
if (window.confirm(msg)) {
successFunc();
}
return this;
};
}(jQuery))
@hiraq
Copy link
Author

hiraq commented Sep 23, 2015

example:

jQuery('#delete_all').on('click', function(e) {
    e.preventDefault();
    jQuery(this).confirmit('Are you sure want to delete all ?', function() {
      console.log('tested');
    });
  });

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