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

  • SEARCH
  • Home
  • 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 7520345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:03:21+00:00 2026-05-30T02:03:21+00:00

What is the best way to bind events to a Backbone boilerplate application? I’ve

  • 0

What is the best way to bind events to a Backbone boilerplate application? I’ve been trying to bind my events directly to the models associated with my views, in my views, but it doesn’t seem to be working. I see within ‘namespace.js’, that there is an app key that extends Backbone.Events like so:

// Keep active application instances namespaced under an app object.
app: _.extend({}, Backbone.Events)

I don’t fully understand how to use it…

I was able to get things working without the boilerplate, but it does provide some very cool functionality, so I’d love to be able to use it. Thanks!

ADDED

the code I was using was with the underscore bind method like so:

this.module.bind('change', this.render);

But then, I realized that ‘this.model’ is returning undefined, and so this doesn’t work. I really am not sure how the boilerplate wants me to reference my model from the view.

  • 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-30T02:03:21+00:00Added an answer on May 30, 2026 at 2:03 am

    I’m not sure if it is a typo that you copied from your code or a typo you only entered here, but I believe this.module (which IS undefined) should be this.model, which you also must be sure to pass in when you instantiate your view, of course, as so:

    myView = new BBView({model: myModel});

    then you can say this.model.bind('change', this.render); or this.model.on('change', this.render); for the most recent version of Backbone

    I frequently bind my views to change events on my models in this way.

    As for extending Backbone.Events, the way I have used it is to create an independent “event aggregator” that will help connect events between different views on your page. Let’s say for example you have some action on one view that needs to set off an action on another view. In this case, you can pass your event aggregator object as an option to each of your views when you instantiate them, so that they can both trigger events or bind to events on a common object (i.e. your event aggregator).

    whatsUp = _.extend({}, Backbone.Events) // the aggregator

    myFirstView = new FirstBBView ({whatsUp: whatsUp});

    (the aggregator shows up as this.options.whatsUp inside the view)

    mySecondView = new SecondBBView2 ({whatsUp: whatsUp});

    inside FirstBBView:

    this.options.whatsUp.bind('specialEvent', function(arg1,arg2) {
    // do stuff
    });

    inside SecondBBView, when something important happens:

    this.options.whatsUp.trigger('specialEvent', {arg1: 'some data', arg2: 'more data'});

    For a great explanation, see this great article by Derick Bailey

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

Sidebar

Related Questions

I am trying to figure out the best way to bind to an unrelated
In a single paged application, would this be the best way to bind and
I'm trying to figure out the best way to bubble up PropertyChanged events from
What is the best way to bind Javascript events to my custom MVC controls?
I have this (simplification): $(li).click(function{alert(test);}); <li> <input> </li> What's the best way to bind
What is the best way to bind a dynamically created collection of elements in
What is the best way to ensure that events are rebound after an UpdatePanel
Help me to find best approach for managing Backbone views. For example I have
What's the best way to handle binding events on elements that will be refreshed
What is the best way to support two views over the same data, with

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.