Fix list-component.js: Use correct bricks API methods - clear_widgets(), add_widget() instead of non-existent refresh() and appendChild()
This commit is contained in:
parent
3182fcdf97
commit
2cda5570dc
@ -48,39 +48,46 @@ bricks.List = class extends bricks.VBox {
|
||||
}
|
||||
|
||||
renderItems() {
|
||||
// Clear existing children by resetting subwidgets array
|
||||
this.subwidgets = [];
|
||||
// Clear existing children
|
||||
this.clear_widgets();
|
||||
|
||||
// Create new item containers and add to subwidgets
|
||||
this.subwidgets = this.items.map((item, index) => {
|
||||
return {
|
||||
widgettype: "VBox",
|
||||
options: {
|
||||
width: "100%",
|
||||
height: this.itemHeight + "px"
|
||||
},
|
||||
_listItemData: item,
|
||||
_listItemIndex: index,
|
||||
binds: [{
|
||||
wid: "self",
|
||||
event: "on_parent",
|
||||
actiontype: "urlwidget",
|
||||
target: "self",
|
||||
// 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',
|
||||
options: {
|
||||
url: this.item_template_url,
|
||||
params: {
|
||||
item: item,
|
||||
index: index,
|
||||
id: "item_" + index
|
||||
id: 'item_' + index
|
||||
}
|
||||
},
|
||||
mode: "replace"
|
||||
}]
|
||||
};
|
||||
mode: 'replace'
|
||||
});
|
||||
|
||||
// In bricks framework, updating subwidgets should automatically trigger re-render
|
||||
// No need for explicit refresh or invalidate calls
|
||||
// Use correct bricks API to add widget
|
||||
this.add_widget(itemContainer);
|
||||
});
|
||||
|
||||
// No need for refresh() call - add_widget should handle rendering
|
||||
}
|
||||
|
||||
// Public method to reload data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user