我一直在尝试遵循本指南:http://developers-club.com/posts/256505/
我根本无法弄清楚为什么$$(“myList”)。refresh()不起作用?我是webix的完全新手,可以使用一些帮助。
我的代码在这里:http://sahanaya.net/webix/webix2.html
{view:"tree", id:"myTree", data:recordsData, select: oceanData, on: {
onSelectChange: function(){
selected = $$("myTree").getSelectedId();
if (isNaN(selected)) {
$$("myList").clearAll();
$$("myList").define("data", selected);
$$("myList").refresh(); <-- THIS DOES NOT WORK ??
coverPath = "imgs/" + selected + ".jpg"
$$("myCover").define("data", { src: coverPath });
}
}
}
答案 0 :(得分:1)
define("data", /**/)
无效。对于data loading (docs),还有另一种方法parse()
此外,一些改进将有用恕我直言
select
是一个布尔属性(是的,这是一个同名方法); selected
变量是一个字符串,如果您想使用相应的变量,请查看详细信息at this topic。refresh()
ready
处理程序来捕获树初始化的时刻这是我建议的树配置:
{
view:"tree",
id:"myTree",
data:recordsData,
select: true, // boolean property.
on: {
onSelectChange: function(){
selected = $$("myTree").getSelectedId();
if (isNaN(selected)) {
var selectedItem = $$("myTree").getItem(selected);
if (selectedItem.$level == 2){ // checks whether it's the 'album' level
$$("myList").clearAll();
$$("myList").parse(window[selected]); // instead of `define`+`refresh`
// note that string ID isn't the variable name, but window[selected] can handle the global variable
coverPath = "imgs/" + selected + ".jpg";
// but `refresh` is required for ui.template:
$$("myCover").data.title = coverPath;
$$("myCover").refresh();
}
}
}
},
ready:function(){
this.open("1");
this.select("oceanData") // therefore, initial var selected can be an empty array
}
}