Skip to content

Instantly share code, notes, and snippets.

@documentprocessing
Created May 6, 2025 00:37
Show Gist options
  • Select an option

  • Save documentprocessing/5c24bc4c8ec221c6d9171af4c8fac6f7 to your computer and use it in GitHub Desktop.

Select an option

Save documentprocessing/5c24bc4c8ec221c6d9171af4c8fac6f7 to your computer and use it in GitHub Desktop.
Checkboxes and Drag and Drop using Javascript
$(document).ready(function() {
$('#advancedTree').jstree({
'plugins': ['checkbox', 'dnd'],
'core': {
'data': [
{
"text": "Documents",
"state": { "opened": true },
"children": [
{ "text": "Project.docx", "type": "file" },
{ "text": "Report.pdf", "type": "file" },
{
"text": "Images",
"children": [
{ "text": "photo1.jpg", "type": "file" },
{ "text": "photo2.png", "type": "file" }
]
}
]
},
{
"text": "Music",
"children": [
{ "text": "song1.mp3", "type": "file" },
{ "text": "song2.mp3", "type": "file" }
]
}
]
},
'checkbox': {
'keep_selected_style': false
},
'types': {
'file': {
'icon': 'fa fa-file'
}
}
});
// Handle checkbox selections
$('#advancedTree').on('changed.jstree', function(e, data) {
console.log('Selected nodes:', data.selected);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment