[英]Why doesn't binding work in knockout in this case?
我有一个我的ViewModel:
Models.DayP = function (data) {
var self = this;
this.Mapping = {
'Actions': {
create: function (options) {
return new App.Models.Action(self, options.data);
}
}
};
}
我有一个ViewModel:
MPViewModel = function () {
this.Model = {};
this.Model.Test = ko.observable();
//ajax request made below to set the data. Testis type of Models.DayP
}
我设置绑定为:
<div data-bind="visible: Model.Test().Actions.length <= 0" style="display:none;"> </div>
问题是这个div总是显示,即使Model.Test().Actions
是在Ajax请求之后设置的,我的div永远不会隐藏自己。
尝试将Actions作为函数调用以获取底层数组:
<div data-bind="visible: Model.Test().Actions().length <= 0" style="display:none;"> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.