Guest User

Untitled

a guest
Aug 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. FadeOut for same link that was clicked
  2. function myalert() {
  3. var result = true;
  4. //var hide = $('.alert').fadeOut(100);
  5. //var css = $('#appriseOverlay').css('display','none');
  6. var $alertDiv = $('<div class="alert">Do you want to delete this item?<button class="ok">ok</button><button class="cancel">cancel</button></div>');
  7. $('body').append($alertDiv);
  8. $('.ok').click(function () {
  9. $('.alert').fadeOut(100);
  10. $('#appriseOverlay').css('display', 'none');
  11. callback(true);
  12. });
  13. $('.cancel').click(function () {
  14. $('.alert').fadeOut(100);
  15. $('#appriseOverlay').css('display', 'none');
  16. callback(false);
  17. });
  18. $alertDiv.fadeIn(100);
  19. $('#appriseOverlay').css('display', 'block');
  20. return result;
  21. };
  22.  
  23. $('.iu').click(myalert)
  24.  
  25. function callback(result) {
  26. //
  27. if (result) {
  28. $(this).fadeOut('slow');//I mean, this part from code
  29. } else {
  30. alert('no')
  31. }
  32. }
  33.  
  34. function myalert() {
  35. var result = true;
  36. //var hide = $('.alert').fadeOut(100);
  37. //var css = $('#appriseOverlay').css('display','none');
  38. var $alertDiv = $('<div class="alert">Do you want to delete this item?<button class="ok">ok</button><button class="cancel">cancel</button></div>');
  39.  
  40. var link = this; //save the clicks link
  41. $('body').append($alertDiv);
  42. $('.ok').click(function () {
  43. $('.alert').fadeOut(100);
  44. $('#appriseOverlay').css('display', 'none');
  45. callback(true, link); //pass along the clicked link
  46. });
  47. $('.cancel').click(function () {
  48. $('.alert').fadeOut(100);
  49. $('#appriseOverlay').css('display', 'none');
  50. callback(false, link);
  51. });
  52. $alertDiv.fadeIn(100);
  53. $('#appriseOverlay').css('display', 'block');
  54. return result;
  55. };
  56.  
  57. $('.iu').click(myalert)
  58.  
  59. function callback(result, link) {
  60. if (result) {
  61. $(link).fadeOut('slow');//fade out the clicked link
  62. } else {
  63. alert('no')
  64. }
  65. }
  66.  
  67. // pass e (the event object to "myalert")
  68. function myalert(e) {
  69. var result = true;
  70. //var hide = $('.alert').fadeOut(100);
  71. //var css = $('#appriseOverlay').css('display','none');
  72. var $alertDiv = $('<div class="alert">Do you want to delete this item?<button class="ok">ok</button><button class="cancel">cancel</button></div>');
  73. $('body').append($alertDiv);
  74. $('.ok').click(function () {
  75. $('.alert').fadeOut(100);
  76. $('#appriseOverlay').css('display','none');
  77.  
  78. // pass the clicked element to the callback function
  79. callback(true, e.target);
  80.  
  81. });
  82. $('.cancel').click(function () {
  83. $('.alert').fadeOut(100);
  84. $('#appriseOverlay').css('display','none');
  85.  
  86. // pass the clicked element to the callback function
  87. callback(false, e.target);
  88.  
  89. });
  90. $alertDiv.fadeIn(100);
  91. $('#appriseOverlay').css('display','block');
  92. return result;
  93. };
  94.  
  95. $('.iu').click(myalert) // the event object will be passed to myalert
  96.  
  97. // takes the result, and the clicked element
  98. function callback(result, el) {
  99. //
  100. if(result){
  101. $(el).fadeOut('slow');
  102. }else{
  103. alert('no')
  104. }
  105. }
Add Comment
Please, Sign In to add comment