Backbone.js的 - 从一个视图到另一个绑定? [英] Backbone.js - Binding from one view to another?

查看:142
本文介绍了Backbone.js的 - 从一个视图到另一个绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主要的应用程序视图,在头一个过滤器菜单。当它的点击,我要过滤在一个单独的新闻饲料查看内容。但我不知道如何从点击在一个视图中绑定事件(并传递类数据)传递给函数在另一个。

I have a main app view, with a filter menu in the header. When it's clicked, I want to filter content in a seperate news-feed view. But I don't know how to bind events (and pass class data) from clicks in one view to a function in another.

我怎样才能做到这一点?

推荐答案

有多种方法来做到这一点,但可能要创建一个模型对象,它是两种观点之间共享。然后在视图中的两个'点击'鉴于之一,更新模型对象,并绑定的变化的模型对象。

There are a number of ways to accomplish this, but probably you want to create a model object, which is shared between the two views. Then on 'click' in view one, update the model object, and bind 'on change' in view two to the model object.

基本上,你可以设置两种观点停留在与模型对象的同步,以及对象的任何更改将导致更改视图。

Basically, you can set up both views to stay in sync with the model object, and any changes to the object will result in changes to the view.

这篇关于Backbone.js的 - 从一个视图到另一个绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆