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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:43:05+00:00 2026-06-03T09:43:05+00:00

Here I have a Backbone.js Model – Contact and a Collection – Contacts with

  • 0

Here I have a Backbone.js Model – Contact and a Collection – Contacts with Contact as the Model. I’ve two views where in one I use collection to list all the contacts and in the second the model directly to show a single contact. But when I’m using the model directly I’m able to get the ‘change’ event fired while using with the collection the ‘change’ event, (even ‘all’ events of the model) is not fired. Am I missing some extra bind here to make it work with collection?

var Contact = Backbone.Model.extend({ 
    defaults: {
        id: 0,
        urlDisplayPicBig: '',
        urlDisplayPicSmall: ''
    },
    initialize: function () {
        this.bind('change', this.doSomething);
    },
    generateUrls: function () { //earlier doSomething()
        ...
    }
    ...
});

var Contacts = Backbone.Collection.extend({ 
    model: Contact,
    ...
});

Update
While using both collection & single model instances I have to run generateUrls() to update urlDisplayPicBig & urlDisplayPicSmall based on the ‘id’ of the model.

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

    When you do fetch on a collection:

    the collection will reset

    and that will

    replace a collection with a new list of models (or attribute hashes), triggering a single "reset" event at the end. […] Using reset with no arguments is useful as a way to empty the collection.

    So a fetch on a collection will remove all the models that are currently in the collection and replace them with brand new model instances. No "change" events will occur, there will only be a single "reset" event.

    When you do a fetch on a model:

    A "change" event will be triggered if the server’s state differs from the current attributes.

    So calling fetch is pretty much the same loading the data from the server manually and calling set to change the model.


    Summary: Collection#fetch doesn’t trigger any "change" events, just a "reset" event; Model#fetch will trigger a "change" event if something changes.


    If you just want to add a couple new attributes when creating new model instances then you can add new attributes to the incoming JSON using Model#parse.

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

Sidebar

Related Questions

I have two backbone Views. One is the main view and the other is
Here is what I have so far: var Item = Backbone.Model.extend({ defaults: { id:
I have a backbone collection and when I remove a model from the collection,
I'm using codebrew\backbone-rails in a nested model example (say I have a collection of
Just wondering what little scripts/programs people here have written that helps one with his
Here i have gridview which contain some values retrieved from database.We put radiobutton list
I use Backbone.js and jQuery 1.7 in my application and I have some problems
I'm looking back at the Backbone todo list and have a question about the
I have a model that has a bunch of attributes but the two of
I have a backbone model called Member - this contains membership data such as

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.