Posted By

koko on 06/26/10


Tagged

jquery confirmation


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

vagrantradio
jackkeller
fenta23


JQuery confirmation (+ fancy)


 / Published in: jQuery
 

URL: http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/

  1. STANDARD
  2. ========
  3.  
  4. $('.ask-plain').click(function(e) {
  5.  
  6. e.preventDefault();
  7. thisHref = $(this).attr('href');
  8.  
  9. if(confirm('Are you sure')) {
  10. window.location = thisHref;
  11. }
  12.  
  13. });
  14.  
  15. FANCY
  16. ======
  17.  
  18. $('.ask').click(function(e) {
  19.  
  20. e.preventDefault();
  21. thisHref = $(this).attr('href');
  22.  
  23. if($(this).next('div.question').length <= 0)
  24. $(this).after('<div class="question">Are you sure?<br/> <span class="yes">Yes</span><span class="cancel">Cancel</span></div>');
  25.  
  26. $('.question').animate({opacity: 1}, 300);
  27.  
  28. $('.yes').live('click', function(){
  29. window.location = thisHref;
  30. });
  31.  
  32. $('.cancel').live('click', function(){
  33. $(this).parents('div.question').fadeOut(300, function() {
  34. $(this).remove();
  35. });
  36. });

Report this snippet  

You need to login to post a comment.