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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:39:07+00:00 2026-06-09T13:39:07+00:00

I am converting my backbone app so that it starts communicating with the server,

  • 0

I am converting my backbone app so that it starts communicating with the server, previously I had just been populating the collection with test data using .add()

I have tied some events to the collections add event. So every time an item is added to the collection I can render the view and update some statistics.

it appears that as soon as i add the .fetch() call to get data from the server the add events stop.

for example

var PayableCommitmentCollection = Backbone.Collection.extend({
    model:PayableCommitment,
    url:"/cc/account/contributions/",

    initialize: function() {
        this.bind("add",this.setInitialAmount,this);
    }
 }

this.SetInitialAmount() is never called after fetch creates the models in the collection.

I also have 2 views that are watching for items to be added to this collection that are now not updating.

My obvious work around is to write my own AJAX call so that I can add the items the same way I have been during development so far, however I’m sure backbone has the smarts to help me out here.

Can anyone suggest a way i can bind to the completion of fetch, or to make it stimulate the add event.

  • 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-09T13:39:08+00:00Added an answer on June 9, 2026 at 1:39 pm

    From the fine manual:

    fetch collection.fetch([options])

    Fetch the default set of models for this collection from the server, resetting the collection when they arrive.

    And a reset:

    reset collection.reset(models, [options])

    Adding and removing models one at a time is all well and good, but sometimes you have so many models to change that you’d rather just update the collection in bulk. Use reset to replace a collection with a new list of models (or attribute hashes), triggering a single "reset" event at the end.

    So a fetch will trigger a single "reset" event rather than a bunch of "add" events. You need a collection-wide version of setInitialAmount that you can bind to "reset".


    In Backbone 1.0, Collection#fetch has this to say:

    fetch collection.fetch([options])

    Fetch the default set of models for this collection from the server, setting them on the collection when they arrive.
    […]
    The behavior of fetch can be customized by using the available set options. For example, to fetch a collection, getting an "add" event for every new model, and a "change" event for every changed existing model, without removing anything: collection.fetch({remove: false})

    So, if you’re using 1.0+ then all you need to do is call your fetch with the remove: false option.

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

Sidebar

Related Questions

I'm working on converting a single-page app to backbone.JS. The View below uses the
While converting and normalizing data from an Access database to a SQL Server database,
I am working on converting a Backbone application into an Ember application using Ember
Converting to ODB.NET from System.Data.OracleClient and need help converting my connection string. Here is
Converting from usind Micorsofts Syste.Data.OracleClient to what I believe is called Oracles ODT (Oracle.DataAccess
After converting a Hybrid ASP.NET MVC1 app to MVC2 I'm getting the following error
Converting another app from Rails 2 to Rails 3 - in one of my
While converting a project that used SlimDX, and therefore has unmanaged code, to .NET
While converting database project to SSDT and upgrading to SQL Server 2012 I need
When converting a data frame with mixed factor and numeric columns to an xts,

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.