Advertisement
Guest User

Untitled

a guest
Nov 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. $('.p-btn').on('click', function(){
  2.  
  3. var row = $(this).parent().parent();
  4. var toTrim = $(row).find('#primary').html();
  5. var trimmed = $.trim(toTrim);
  6. console.log(trimmed);
  7.  
  8. if(trimmed == 'DEL') {
  9. $(this).on('click', function() {
  10. alert('boom');
  11. });
  12. }
  13. else if(trimmed == 'CONFIRM') {
  14. var user_id = $("#uid").val();
  15. var username = $("#uuname").val();
  16. var password = $("#upass").val();
  17. var role = $("#rolename").val();
  18. var active = $("#uactive").val();
  19.  
  20. //alert(user_id + " " +username + " " + password + " " + role + " " + active);
  21. $.post("user/edit.php", {
  22. user_id = user_id,
  23. username = username,
  24. password = password,
  25. role = role,
  26. active = active
  27. }, function(data) {
  28. alert(data + " Successful");
  29. $('#editform')[0].reset();
  30. });
  31.  
  32.  
  33. //formSubmit();
  34. // alert(1);
  35. }
  36.  
  37.  
  38. else {
  39. var btn=document.getElementById('primary');
  40.  
  41. $(row).find('span').css('display', 'none');
  42. $(row).find('input[type="hidden"]').attr('type', 'text');
  43. $(row).find('select').show();
  44. $('table button').attr('disabled', 'disabled');
  45. $(row).find('#primary').html('CONFIRM').removeAttr('disabled');
  46.  
  47. $(row).find('#secondary').html('CANCEL').removeAttr('disabled');
  48. }
  49. });
  50.  
  51.  
  52.  
  53.  
  54.  
  55. //Secondary Button Cancel Action
  56. $('.s-btn').on('click', function(){
  57. var row = $(this).parent().parent();
  58. var toTrim = $(row).find('#secondary').html();
  59. var trimmed = $.trim(toTrim);
  60. console.log(trimmed);
  61. if(trimmed == 'CANCEL') {
  62. var row = $(this).parent().parent();
  63. $(row).find('span').show();
  64. $(row).find('input[type="text"]').attr('type', 'hidden');
  65. $(row).find('select').css('display', 'none');
  66. $('table button').removeAttr('disabled');
  67. $(row).find('#primary').html($.trim('EDIT')).removeAttr('disabled');
  68. $(row).find('#secondary').html($.trim('DELETE')).removeAttr('disabled');
  69. }
  70.  
  71. if(trimmed == 'DELETE') {
  72. $(row).find('span').css('display', 'none');
  73. $(row).find('input[type="hidden"]').attr('type', 'text');
  74. $(row).find('select').show();
  75. $('table button').attr('disabled', 'disabled');
  76. $(row).find('#primary').html('DEL').removeAttr('disabled');
  77. $(row).find('#secondary').html('CANCEL').removeAttr('disabled');
  78. }
  79. });
  80.  
  81.  
  82. });
  83. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement