使用Knockout数据绑定分层JSON

时间:2013-04-24 10:48:22

标签: data-binding knockout.js

我想使用Knockout将结构绑定到从REST服务返回的分层JSON。采用以下形式:

[{
    Name: "Page 1",
    Children: [ {
        Name: "Page 1 > 1",
        Children: [{
        Name: "Page 1 > 1 > 1",
        Children: []
    }
,{
        Name: "Page 1 > 1 > 2",
        Children: []
    }
]
    }
    ]
},
{
    Name: "Page 2",
    Children: [
    {
        Name: "Page 16",
        Children: []
    }
    ]
},
{
    Name: "Page 3",
    Children: [
    {
        LocalizedName: "aaaaa",
        Children: []
    }
]

标准(foreach)绑定仅返回顶级。有没有好办法呢?

感谢。

0 个答案:

没有答案