diff --git a/bricks/bricks.js b/bricks/bricks.js index 5ab7fcd..7d6299e 100644 --- a/bricks/bricks.js +++ b/bricks/bricks.js @@ -614,10 +614,14 @@ bricks.getWidgetById = function(idset, from_widget){ } var el = fromw.dom_element; var nel; + // id 可能是层级路径的末段(DOM id 为完整路径如 app.world_content), + // 先精确匹配,再按 ".末段" 后缀兜底;CSS.escape 防点号被当 class 选择器 + var selExact = '#' + (window.CSS && CSS.escape ? CSS.escape(id) : id); + var selSuffix = '[id$=".' + (window.CSS && CSS.escape ? CSS.escape(id) : id) + '"]'; if(downward ){ - nel = el.querySelector('#' + id); + nel = el.querySelector(selExact) || el.querySelector(selSuffix); } else { - nel = el.closest('#' + id); + nel = el.closest(selExact) || el.closest(selSuffix); } if (!nel) { console.log('get_by_id() return null',id, fromw, downward); diff --git a/bricks/header.tmpl b/bricks/header.tmpl index f82c990..e4074c1 100644 --- a/bricks/header.tmpl +++ b/bricks/header.tmpl @@ -37,7 +37,7 @@ - + {% for myjs in jsfiles() %} {% endfor %}