[英]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.