Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('.p-btn').on('click', function(){
- var row = $(this).parent().parent();
- var toTrim = $(row).find('#primary').html();
- var trimmed = $.trim(toTrim);
- console.log(trimmed);
- if(trimmed == 'DEL') {
- $(this).on('click', function() {
- alert('boom');
- });
- }
- else if(trimmed == 'CONFIRM') {
- var user_id = $("#uid").val();
- var username = $("#uuname").val();
- var password = $("#upass").val();
- var role = $("#rolename").val();
- var active = $("#uactive").val();
- //alert(user_id + " " +username + " " + password + " " + role + " " + active);
- $.post("user/edit.php", {
- user_id = user_id,
- username = username,
- password = password,
- role = role,
- active = active
- }, function(data) {
- alert(data + " Successful");
- $('#editform')[0].reset();
- });
- //formSubmit();
- // alert(1);
- }
- else {
- var btn=document.getElementById('primary');
- $(row).find('span').css('display', 'none');
- $(row).find('input[type="hidden"]').attr('type', 'text');
- $(row).find('select').show();
- $('table button').attr('disabled', 'disabled');
- $(row).find('#primary').html('CONFIRM').removeAttr('disabled');
- $(row).find('#secondary').html('CANCEL').removeAttr('disabled');
- }
- });
- //Secondary Button Cancel Action
- $('.s-btn').on('click', function(){
- var row = $(this).parent().parent();
- var toTrim = $(row).find('#secondary').html();
- var trimmed = $.trim(toTrim);
- console.log(trimmed);
- if(trimmed == 'CANCEL') {
- var row = $(this).parent().parent();
- $(row).find('span').show();
- $(row).find('input[type="text"]').attr('type', 'hidden');
- $(row).find('select').css('display', 'none');
- $('table button').removeAttr('disabled');
- $(row).find('#primary').html($.trim('EDIT')).removeAttr('disabled');
- $(row).find('#secondary').html($.trim('DELETE')).removeAttr('disabled');
- }
- if(trimmed == 'DELETE') {
- $(row).find('span').css('display', 'none');
- $(row).find('input[type="hidden"]').attr('type', 'text');
- $(row).find('select').show();
- $('table button').attr('disabled', 'disabled');
- $(row).find('#primary').html('DEL').removeAttr('disabled');
- $(row).find('#secondary').html('CANCEL').removeAttr('disabled');
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement