Created
July 10, 2014 09:10
-
-
Save drakakisgeo/d22a569feae0746baebe to your computer and use it in GitHub Desktop.
On click Confirm popup (Jquery)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Info: Attach event to all elements with this data attribute | |
| // works even for elements that will be created afterwards by Ajax or Jquery | |
| // Only thing you do is to put a data-popmsg attribute in the element you want to click and the value of this attribute | |
| // will be the body of the popup. | |
| $(document).on("click","*[data-popmsg]",function(e){ | |
| var msg = $(this).attr("data-popmsg"); | |
| if(!confirm(msg)) | |
| { | |
| e.preventDefault(); | |
| } | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Asterisk(*) is a bit expensive. If you have certain selectors use something more specific to gain some speed.