0
嗨,我希望能够绑定基于数组值的表中项目的可见性。Knockout:在可观察数组中设置属性值的可视性基础
我有
<input type="text" value="2" data-bind="visible: this.arrayVal[2].name == 'RST'/>
等,我有jQuery来生成所述数据绑定值。它是否正确?
另外我如何动态初始化该值。 N行的表的示例,我想将该值绑定到10行的可观察数组?
因此,要清除这是我写的,因为我无法控制的HTML,我使用Jquery添加数据绑定。
function addDataBind(index) {
var selectItem, textItem;
selectItem = $("#input" + index + "selectItem");
textItem = $("#input" + index + "textItem");
if (selectItem.length && textItem.length) {
selectItem.attr("data-bind", "value: arrayVal[" + index + "], valueUpdate: 'afterkeydown'"
textItem.attr("data-bind", "visible: arrayVal[" + index + "] == 'RST'");
}
}
使用this.arrayVal()[$ index]在firefox中无效,但在chrome中工作。 ,但使用this.arrayVal [$ index]在Firefox和Chrome都可以使用。