繁体   English   中英

在这种情况下,为什么没有绑定工作在淘汰赛?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM