diff --git a/wwwroot/list-component.js b/wwwroot/list-component.js index 1265b85..cf952f0 100644 --- a/wwwroot/list-component.js +++ b/wwwroot/list-component.js @@ -48,47 +48,39 @@ bricks.List = class extends bricks.VBox { } renderItems() { - // Clear existing children + // Clear existing children by resetting subwidgets array this.subwidgets = []; - this.children.forEach(child => child.remove()); - this.children = []; - // Render each item using urlwidget to load the item template - this.items.forEach((item, index) => { - const itemContainer = new bricks.VBox({ - width: '100%', - height: this.itemHeight + 'px' - }); - - // Store item data on the container for reference - itemContainer._listItemData = item; - itemContainer._listItemIndex = index; - - // Create urlwidget binding to load the item template - if (!itemContainer.binds) { - itemContainer.binds = []; - } - - itemContainer.binds.push({ - wid: 'self', - event: 'on_parent', - actiontype: 'urlwidget', - target: 'self', + // Create new item containers and add to subwidgets + this.subwidgets = this.items.map((item, index) => { + return { + widgettype: "VBox", options: { - url: this.item_template_url, - params: { - item: item, - index: index, - id: 'item_' + index - } + width: "100%", + height: this.itemHeight + "px" }, - mode: 'replace' - }); - - this.appendChild(itemContainer); + _listItemData: item, + _listItemIndex: index, + binds: [{ + wid: "self", + event: "on_parent", + actiontype: "urlwidget", + target: "self", + options: { + url: this.item_template_url, + params: { + item: item, + index: index, + id: "item_" + index + } + }, + mode: "replace" + }] + }; }); - this.refresh(); + // In bricks framework, updating subwidgets should automatically trigger re-render + // No need for explicit refresh or invalidate calls } // Public method to reload data