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 9247827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:49:57+00:00 2026-06-18T09:49:57+00:00

I have a view that takes a collection like below: MyView = Backbone.View.extend({ initialize:

  • 0

I have a view that takes a collection like below:

MyView = Backbone.View.extend({
    initialize: function() {
       this.collection.on("change://an attribute of a model in aCollectionToRender", someAction);
    }
});

var MyViewInstance = new MyView({
    collection: aCollectionToRender
});

Basically, I don’t want MyView to listen for changes on the entire collection, only a single attribute of the model that the collection contains.

I realize there are a number of alternatives to this:

  1. Create views for each model of aCollectionToRender and attach .on("change") events in those views. I don’t want to do this because it’s not the right thing to do for my situation
  2. Just have a this.collection.on("change") event and have the event handler filter based on my requirements. This is less elegant, and if Backbone already allows me to write event filters as I asked above, this is duplicate code

I was just wondering if there’s any way to write an event listener that already does the filtering. This question may also be a duplicate; I looked but I didn’t find anything exactly like this, however, there are a lot of Backbone questions

  • 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-06-18T09:49:58+00:00Added an answer on June 18, 2026 at 9:49 am

    Maybe I am misunderstanding your question, but you can do exactly what you show. Check out the Backbone documentation.

    MyView = Backbone.View.extend({
        initialize: function() {
           this.collection.on("change:attributeName", this.someAction /*function to call*/, this);
        },
        someAction: function(model, value, options){
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl
I have a view that takes data from my site and then makes it
I have a single-view application that takes in a username and a password and
OK so I have a strongly-typed Customer Details view that takes a Customer object
I have a model that looks like this: class Pdf extends \lithium\data\Model { protected
I have a huge collection of visual foxpro dbf files that I would like
I have a view that can take several seconds to process a GET request
I have a partial view that I want to basically take care of itself
I am beginner in rails. I have view that i try to print inside
I have a view that has a column to make it sortable. When clicking

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.