Skip to content
Snippets Groups Projects
Commit 6e519e96 authored by Mingsong's avatar Mingsong Committed by Mingsong Hu
Browse files

Issue #3341369 by SirClickALot, Mingsong: No tree visible on clean install on Drupal 10

parent e66814d6
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ feature.hm.jstree: ...@@ -10,6 +10,7 @@ feature.hm.jstree:
- hierarchy_manager/libraries.jquery.jstree - hierarchy_manager/libraries.jquery.jstree
- core/drupalSettings - core/drupalSettings
- core/drupal.message - core/drupal.message
- core/once
feature.hm.jsoneditor: feature.hm.jsoneditor:
js: js:
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
// Codes run both on normal page loads and when data is loaded by AJAX (or BigPipe!) // Codes run both on normal page loads and when data is loaded by AJAX (or BigPipe!)
// @See https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview // @See https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview
(function($, Drupal) { (function($, Drupal, once) {
Drupal.behaviors.hmJSTree = { Drupal.behaviors.hmJSTree = {
attach: function(context, settings) { attach: function(context, settings) {
$(".hm-jstree", context) const hmJstree = once('hmJSTree', '.hm-jstree', context);
.once("jstreeBehavior") // Render all trees.
.each(function() { hmJstree.forEach(function(hmJstree) {
const treeContainer = $(this); const treeContainer = $(hmJstree);
const parentID = treeContainer.attr('parent-id'); const parentID = treeContainer.attr('parent-id');
const searchTextID = (parentID) ? '#hm-jstree-search-' + parentID : '#hm-jstree-search'; const searchTextID = (parentID) ? '#hm-jstree-search-' + parentID : '#hm-jstree-search';
const optionsJson = treeContainer.attr("options"); const optionsJson = treeContainer.attr("options");
...@@ -251,4 +251,4 @@ ...@@ -251,4 +251,4 @@
return modalConfirmationForm.dialog('open'); return modalConfirmationForm.dialog('open');
} }
})(jQuery, Drupal); })(jQuery, Drupal, once);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment