1
我從服務器獲取某種樹的數據(只是例子):骨幹:渲染樹數據和更新變化
[
{
nodeName: "top level 1",
nodes: [
{
nodeName: "2nd level, item 1",
nodes: [
{
nodeName: "3rd level, item 1"}
]}
]},
{
nodeName: "top level 2",
nodes: [
{
nodeName: "2nd level, item 3",
nodes: [
{
nodeName: "3rd level, item 7"},
{
nodeName: "3rd level, item 8"},
{
nodeName: "3rd level, item 9"}
]}
]}
]
要使用Backbone.Marionette.CollectionView &骨幹呈現此我'。 Marionette.CompositeView http://jsfiddle.net/AdWjU/179/(以下derickbailey's article)。
但我需要輪詢服務器每300秒,它可以返回改變樹:
[
{
nodeName: "top level 1",
nodes: [
{
nodeName: "2nd level, item 1",
nodes: [
{
nodeName: "3rd level, item 1"},
{
nodeName: "new name"} // changed
]}
]},
{
nodeName: "top level 2",
nodes: [
{
nodeName: "2nd level, item 3",
nodes: [
{
nodeName: "3rd level, item 7"},
{
nodeName: "3rd level, item 8"},
{
nodeName: "3rd level, item 9"},
{
nodeName: "3rd level, item 10"} // added
]}
]}
]
現在我只需調用tree.update(數據)重新呈現整個數據。
如何僅更新取決於已更改屬性的視圖?
我試圖減少意見,這是重新渲染。我應該使用CompositeViews還是嘗試使用Backbone-relational模型來完成此任務?
隨時接受答案或要求澄清。 –