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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:10:33+00:00 2026-05-30T19:10:33+00:00

I have a backbone model called Member – this contains membership data such as

  • 0

I have a backbone model called Member – this contains membership data such as first name, last name, email, phone, etc. It also includes multi-valued fields that I need to keep as collections – these are Degrees and Affiliations.

The issue I am running into when calling the fetch() method in my model is that there’s an impedance mismatch of sorts between a basic array, and the collection objects I have in my model. Since parse by definition is supposed to return a hash to be used in set rather than actually setting values, it is impossible for me to set my collections this way. For instance – if I return a JavaScript object for Degrees that looks something like the following: {degrees: [{id: 1, title: "PhD"}]}, then this converts my degree collection into a flat array. Here is my code:

window.Models.Member = Backbone.Model.extend({

    url: '/api/member',

    initialize: function() {

        _.bindAll(this);

        this.set('degrees', new window.Collections.DegreesList());

        this.fetch();

    },

    parse: function(response) {

        var setHash = {};

        setHash.first_name = response.first_name;
        setHash.last_name = response.last_name;
        setHash.office_phone = response.office_phone;

        // When this is run, this.get('degrees') will now return a flat array rather than a DegreesList collection
        setHash.degrees = _(response.degrees).each(function(item) { 
                return {id: item.id, title: item.title} 
        });

        return setHash;

    }

});

I could manually set the collections in my parse function, but that seems like its subverting the Backbone way, and hacky.

EDIT: I’ve temporarily solved the problem by doing the following:

parse: function(response) {

    var setHash = {};

    setHash.first_name = response.first_name;
    setHash.last_name = response.last_name;
    setHash.office_phone = response.office_phone;

    this.get('degrees').reset( response.degrees );

    return setHash;     
}

I doubt this is the optimal solution, but it certainly works for now. I’m open to better suggestions.

  • 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-30T19:10:34+00:00Added an answer on May 30, 2026 at 7:10 pm

    I use exactly the same workaround you are proposing except with a few changes.

    1. To avoid misunderstanding I call the collection in the JSON: degreesData
    2. In the initialize I create the collection like this: this.degrees = new Degrees().reset( this.get( "degreesData" ) );
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple demo app like this Friend = Backbone.Model.extend name:null Friends =
I have this: var SomeNamespace = { Model: Backbone.Model.extend(), View: Backbone.View.extend({ model: new this.Model,
Newbie backbone question: Context: Building a shopping list with backbone I have a model
I have a Backbone Model: class DateTimeSelector extends Backbone.Model initialize: -> @bind 'change:date', @updateDatetime
Using the following as an example: var Case = Backbone.Model.extend({ initialize: function(){ this.bind(error, function(model,
I have a backbone view - which when called presents a form $('#add-offer').click(function() {
I have a view and collection like this: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events:
I have the following Backbone.js model and collection: // Model lr.Event = Backbone.Model.extend({}); //
I have a backbone-Model. With model.set() I can set a local value, with model.save()
I have a backbone.js model similar to the one shown below. Filters = Backbone.Model.extend({

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.