Fix list-component.js: Remove non-existent refresh() method and use proper subwidgets array management for bricks framework compatibility
This commit is contained in:
parent
e726abcddb
commit
3182fcdf97
@ -48,47 +48,39 @@ bricks.List = class extends bricks.VBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderItems() {
|
renderItems() {
|
||||||
// Clear existing children
|
// Clear existing children by resetting subwidgets array
|
||||||
this.subwidgets = [];
|
this.subwidgets = [];
|
||||||
this.children.forEach(child => child.remove());
|
|
||||||
this.children = [];
|
|
||||||
|
|
||||||
// Render each item using urlwidget to load the item template
|
// Create new item containers and add to subwidgets
|
||||||
this.items.forEach((item, index) => {
|
this.subwidgets = this.items.map((item, index) => {
|
||||||
const itemContainer = new bricks.VBox({
|
return {
|
||||||
width: '100%',
|
widgettype: "VBox",
|
||||||
height: this.itemHeight + 'px'
|
options: {
|
||||||
});
|
width: "100%",
|
||||||
|
height: this.itemHeight + "px"
|
||||||
// Store item data on the container for reference
|
},
|
||||||
itemContainer._listItemData = item;
|
_listItemData: item,
|
||||||
itemContainer._listItemIndex = index;
|
_listItemIndex: index,
|
||||||
|
binds: [{
|
||||||
// Create urlwidget binding to load the item template
|
wid: "self",
|
||||||
if (!itemContainer.binds) {
|
event: "on_parent",
|
||||||
itemContainer.binds = [];
|
actiontype: "urlwidget",
|
||||||
}
|
target: "self",
|
||||||
|
|
||||||
itemContainer.binds.push({
|
|
||||||
wid: 'self',
|
|
||||||
event: 'on_parent',
|
|
||||||
actiontype: 'urlwidget',
|
|
||||||
target: 'self',
|
|
||||||
options: {
|
options: {
|
||||||
url: this.item_template_url,
|
url: this.item_template_url,
|
||||||
params: {
|
params: {
|
||||||
item: item,
|
item: item,
|
||||||
index: index,
|
index: index,
|
||||||
id: 'item_' + index
|
id: "item_" + index
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mode: 'replace'
|
mode: "replace"
|
||||||
|
}]
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.appendChild(itemContainer);
|
// In bricks framework, updating subwidgets should automatically trigger re-render
|
||||||
});
|
// No need for explicit refresh or invalidate calls
|
||||||
|
|
||||||
this.refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public method to reload data
|
// Public method to reload data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user