Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
jstree confirm before delete

I would like to ask user, delete or not delete then call ajax.

But but where should the $.confirm method be?

Above code delete first for user screen then delete at backend.

How to call before $.confirm method delete?

$("#kt_tree_type-make-model").jstree({
  "core": {
    "check_callback": true,
    "data": data
  },
  "types": {
    "default": {
      "icon": "fa fa-folder text-primary"
    },
    "file": {
      "icon": "fa fa-file  text-primary"
    }
  },
  "contextmenu":{
    'items' : function(node) {
      var items = $.jstree.defaults.contextmenu.items();
      items.create.label = 'ADD';
      items.rename.label = 'RENAME';
      items.remove.label = 'DELETE';
      items.ccp = false;

      return items;
    }
  },
  "plugins": ["contextmenu", "state", "types"]
}).on('create_node.jstree', function (e, data) {
}).on('rename_node.jstree', function (e, data) {
}).on('delete_node.jstree', function (e, data) {
  $.confirm({
    type: 'orange',
    title: 'ARE YOU SURE?',
    content: 'DELETING.',
    buttons: {
      confirm: {
        text: 'YES, DELETE',
        action: function () {
          let node = data.node.id.split('_');
          let kind = node[0];
          let id = node[1];
          $.ajax({
            url: `/vehicles/type-make-model/${kind}/delete/${id}`,
            type: 'get',
            headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')},
            dataType: 'json',
            success: function (response) {
              $.alert({title: false, type: 'green', content: 'Deleted successfully.'});
              data.instance.refresh();
            },
            error: function (xhr, ajaxOptions, thrownError) {
              $.alert({title: false, type: 'red', content: xhr.responseJSON.message});
              data.instance.refresh();
            }
          });
        }
      },
      cancel: {
        text: 'CANCEL'
      }
    }
  });
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!