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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:55:35+00:00 2026-05-31T08:55:35+00:00

I have been using Backbone on a new project and so far have loved

  • 0

I have been using Backbone on a new project and so far have loved it, but I have come to a blocker that I can’t seem to get around.

Without trying to explain my whole domain model, I have found that when you save a model, the response comes back from the server and gets parsed again, creating new sub objects and therefore breaking and event bindings I had previously put on the object.

For instance, if I save ContentCollection (its a Backbone.Model not a collection) when it comes back from the server, the response gets parsed and creates a new Collection in this.contentItems, which breaks all the binding I had on this.contentItems. Is there any way to get around this? Tell backbone not to parse the response somehow? Grab the bindings off the original list, and then re-attach them to the new list?

App.ContentCollection = Backbone.Model.extend({
    urlRoot: '/collection',

    initialize: function() {
    },

    parse: function(resp, xhr) {
        this.contentItems = new App.ContentList(resp.items)
        this.subscriptions = new App.SubscriptionList(resp.subscriptions)

        return resp
    },

    remove: function(model){
        this.contentItems.remove(model)
        this.save({'removeContentId':model.attributes.id})
    },

    setPrimaryContent: function(model){
        this.save({'setPrimaryContent':model.attributes.id})
    }
})

Has anyone run into this before?

  • 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-31T08:55:37+00:00Added an answer on May 31, 2026 at 8:55 am

    I think the issue here is the way you’re using the parse() method. Backbone just expects this method to take a server response and return a hash of attributes – not to change the object in any way. So Backbone calls this.parse() within save(), not expecting there to be any side-effects – but the way you’ve overridden .parse(), you’re changing the model when the function is called.

    The way I’ve dealt with this use case in the past is to initialize the collections when you first call fetch(), something like:

    App.ContentCollection = Backbone.Model.extend({
    
        initialize: function() {
            this.bind('change', initCollections, this);
        },
    
        initCollections: function() {
            this.contentItems = new App.ContentList(resp.items);
            this.subscriptions = new App.SubscriptionList(resp.subscriptions);
            // now you probably want to unbind it,
            // so it only gets called once
            this.unbind('change', initCollections, this)
        },
    
        // etc
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using ASP.NET for years, but I can never remember when using
I know it's possible to have get and post, but I'm using Backbone.js where
I have been using Castle MonoRail for the last two years, but in a
I have a project that involves three frontend developers. We're going to use backbone
I have been using Apache on my local LAN. The problem is that i
I have been using form inheritance for a while now but without doing much
I have been using the python logging module for quite some time now, but
We have been using MongoDB as our main datastore for a little while but
I have been using doctrine with zend in a project without modules. It is
I know other posts have been made regarding this, but so far the answers

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.