Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backbone.js - Binding from one view to another?

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.

How can I accomplish this?

like image 627
Danny Anges Avatar asked Aug 03 '11 17:08

Danny Anges


1 Answers

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.

like image 81
idbentley Avatar answered Sep 21 '22 13:09

idbentley