Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('#usersTable').dataTable().fnSetFilteringDelay(450);
  2.  
  3.  
  4. $('body').unbind().on('click', '.select-user-button, #addNewUser', function(){
  5.     createShowDangerInput();
  6.     action = $(this).data('action');
  7.     userId = $(this).data('user-id');
  8.  
  9.     clearForm();
  10.  
  11.     if(action == 'edit'){
  12.         $.ajax({
  13.             url: '/pomocnik/user/'+userId,
  14.             success: function(data) {
  15.                 $.each(data, function(index, value) {
  16.                     $('#user-create-show-modal .'+index).val(value);
  17.                 });
  18.             },
  19.             error: function(error) {
  20.                 console.log(error);
  21.             }
  22.         });
  23.  
  24.     }
  25.     enableSaveUser(action, userId);
  26.     $('#user-create-show-modal').modal('show');
  27. });
  28.  
  29. $('body').unbind().on('click', '.delete-user-button', function(){
  30.  
  31.     userId = $(this).data('user-id');
  32.     swal({
  33.         title: "Opravdu chcete tohoto uživatele odebrat ze systému?",
  34.         type: "warning",
  35.         showCancelButton: true,
  36.         confirmButtonColor: "#DD6B55",
  37.         confirmButtonText: "Ano, smazat!",
  38.         closeOnConfirm: true,
  39.         html: false
  40.     }, function() {
  41.         $.ajaxSetup(
  42.         {
  43.             headers:
  44.             {
  45.                 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  46.             }
  47.         });
  48.         $.ajax({
  49.             type: 'DELETE',
  50.             url: '/pomocnik/user/'+userId+'/delete',
  51.             success: function(data)
  52.             {
  53.                 dataTable.ajax.reload()
  54.             },
  55.             error: function (data)
  56.             {
  57.  
  58.                 // console.log('Error:', data);
  59.                 $('#delete').button('reset');
  60.                 return $.jGrowl({
  61.                     message: "Nepodařilo se vymazat zákazníka",
  62.                     theme: 'bg-danger'
  63.                 });
  64.             }
  65.         });
  66.     });
  67. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement