简体   繁体   English

您如何在ribs.js中处理这种类型的更新?

[英]How do you handle this type of update in backbone.js?

This object lives on the client: 该对象位于客户端上:

{
    item1: {thing1:'one', thing2:'two'},
    item2: {thing1:'one', thing2:'two'}
}

This gets sent from the server. 这是从服务器发送的。

{
    item1: {thing1:'ten', thing2:'twenty'},
    item2: {thing1:'one', thing2:'two'},
    item3: {thing1:'ten', thing2:'twenty'}
}

Each item is a view and DOM element. 每个项目都是一个视图和DOM元素。

How do I know when to update an existing view/dom element and when to add a new view/dom element? 我如何知道何时更新现有视图/ dom元素以及何时添加新视图/ dom元素?

You create a model and a collection for this model. 您创建一个模型和该模型的集合。 Once you call fetch on the collection, backbone willc all your backend and fetch the new data. 在集合上调用提取后,主干将在您的所有后端提取新数据。 Once it is finished processing the query and received the data it will trigger a refresh event on the collection. 完成查询处理并接收到数据后,它将触发集合上的刷新事件。 Listen to that event and refresh the UI accordingly. 收听该事件并相应地刷新UI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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