From dccda98cec6a9a4211e8b45d83c7ec1f616bd8b0 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 12 Mar 2024 18:44:23 +0800 Subject: [PATCH] bugfix --- bricks/bricks.js | 13 ++- bricks/css/bricks.css | 4 + bricks/dynamicaccordion.js | 185 ++++++++++++++++++++++++++----------- 3 files changed, 145 insertions(+), 57 deletions(-) diff --git a/bricks/bricks.js b/bricks/bricks.js index b010bd8..0157ffe 100755 --- a/bricks/bricks.js +++ b/bricks/bricks.js @@ -69,7 +69,13 @@ dispatch_event: params: */ -bricks.widgetBuild = async function(desc, widget){ +bricks.apply_data = function(desc, data){ + var tmpl = JSON.stringify(desc); + var s = bricks.obj_fmtstr(data, tmpl); + return JSON.parse(s); +} + +bricks.widgetBuild = async function(desc, widget, data){ if (! widget){ widget = bricks.Body; } @@ -85,6 +91,9 @@ bricks.widgetBuild = async function(desc, widget){ desc = desc1; klassname = desc.widgettype; } + if (data){ + desc = bricks.apply_data(desc, data); + } let klass = bricks.Factory.get(desc.widgettype); if (! klass){ bricks.debug('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw); @@ -99,7 +108,7 @@ bricks.widgetBuild = async function(desc, widget){ if (w.is_container() && desc.subwidgets){ for (let i=0; i