Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#usersTable').dataTable().fnSetFilteringDelay(450);
- $('body').unbind().on('click', '.select-user-button, #addNewUser', function(){
- createShowDangerInput();
- action = $(this).data('action');
- userId = $(this).data('user-id');
- clearForm();
- if(action == 'edit'){
- $.ajax({
- url: '/pomocnik/user/'+userId,
- success: function(data) {
- $.each(data, function(index, value) {
- $('#user-create-show-modal .'+index).val(value);
- });
- },
- error: function(error) {
- console.log(error);
- }
- });
- }
- enableSaveUser(action, userId);
- $('#user-create-show-modal').modal('show');
- });
- $('body').unbind().on('click', '.delete-user-button', function(){
- userId = $(this).data('user-id');
- swal({
- title: "Opravdu chcete tohoto uživatele odebrat ze systému?",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "Ano, smazat!",
- closeOnConfirm: true,
- html: false
- }, function() {
- $.ajaxSetup(
- {
- headers:
- {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- type: 'DELETE',
- url: '/pomocnik/user/'+userId+'/delete',
- success: function(data)
- {
- dataTable.ajax.reload()
- },
- error: function (data)
- {
- // console.log('Error:', data);
- $('#delete').button('reset');
- return $.jGrowl({
- message: "Nepodařilo se vymazat zákazníka",
- theme: 'bg-danger'
- });
- }
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement