Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:43:24+00:00 2026-05-27T06:43:24+00:00

I have a Backbone view named Foo which has a scrollbar. When the scrollbar

  • 0

I have a Backbone view named Foo which has a scrollbar. When the scrollbar is moved in a certain direction I want to have other views in my application change in various ways. These views are not nested inside of Foo — they are completely separate and managed independently.

Should I pass references to all the other views into Foo’s constructor so that it can manually update them? Or should I use events to notify these other views of the scrollbar movement? If so, what object should the event be triggered on by Foo, and listened to by the other views?

These are purely visual changes and there is no model backing them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:43:25+00:00Added an answer on May 27, 2026 at 6:43 am

    i would use events in this case

    take this example:

    NavigationView = Backbone.View.extend({
      initialize: function(options){
        options.events.bind("navigation:change", this.changeNavigation);
        this.render();
      },
    
      changeNavigation: function(key){
        $('.menuItem', $(this.el)).removeClass("active");
        $('.menuItem', $(this.el)).filter("." + key).addClass("active");
      },
    
       render: function(){
         // rendering goes on here....
    
       }
    });
    
    UserListView = Backbone.View.extend({
    
      initialize: function(options){
        options.events.trigger("navigation:change", "users");
        this.render();
      },
    
      render: function() {
        // rendering goes on here....
    
      }
    });
    
    // kickstart the application
    
    var myEvents = _.extend({}, Backbone.Events);
    
    var myNavigation  = new NavigationView({events: myEvents});
    
    // this is just a collection of users... i left it out as it is not really the point here...
    var users = new UserList(); 
    
    var myUserList = new UserListView({collection: users, events: myEvents});
    

    should you need more info, on either referencing 1 view to another, or events, you can also take a good look at this article by Derick Bailey, he explains the above method as an eventAggregator and lists a documented example on how to work with it (and alternatives).
    http://lostechies.com/derickbailey/2011/07/19/references-routing-and-the-event-aggregator-coordinating-views-in-backbone-js/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a generic subclass of Backbone.View which has a close event listener. var
I have a view which doesn't seem to want to render as the model's
I have the backbone.js view below: class MyApplication.Views.Cake extends Backbone.View tagName: 'li' className: 'cake'
I have the following views: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events: { click .getWhois:
I have a view and collection like this: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events:
I have a view that creates and populates a Selectlist. I want to bind
As in the backbone-todolist example,I have a collection of elements. I made 2 views,
I have the following method on a backbone view defined in coffeescript: saveObservation: =>
I have this: var SomeNamespace = { Model: Backbone.Model.extend(), View: Backbone.View.extend({ model: new this.Model,
I am enjoying backbone.js more and more. I desire to have multiple views for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.