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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:02:11+00:00 2026-05-27T20:02:11+00:00

//Model var Dog = Backbone.Model.extend({ name:”, breed:” }); //Collection var Dogs = Backbone.Collection.extend({ model

  • 0
//Model
var Dog = Backbone.Model.extend({
    name:'',
    breed:''

});


//Collection
var Dogs = Backbone.Collection.extend({
    model : Dog,
    url : '/dogs'

    parse : function(res) 
    {
        alert('response' + res);
    return res;
    }

});

This is the JSON objec that I receive from server which is implemented using Jersey.
I return a List of DogModel from Server, it is converted to JSON

@Produces(MediaType.APPLICATION_JSON)

{"DogModel":[{"name":"Jane","breed":"Great Dane"},
{"name":"Rocky","breed":"golden Retriver"},
{"name":"Jim","breed":"Lab"}]}

Wonder I haven’t understood the usage of Collection and its url attribute correctly.
My assumption is that, when ever fetch is called on Collection, it’ll fetch the dogs details from the server and populate the collection.

I do get the response as stated above but the collection is not populated as expected.

What should I do to automatically populate the list of models with the collection?
Do I need to work on the representation of JSON objects?

Help Appreciated!!!

  • 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-27T20:02:12+00:00Added an answer on May 27, 2026 at 8:02 pm

    The parse function needs to return the array of dogs. So you can update your code as follows.

    parse : function(res) 
    {
        alert('response' + res);
        return res.DogModel;
    }
    

    On a side note, you want to declare your model’s default attribute values on the defaults hash like the code below shows (see documentation)

    var Dog = Backbone.Model.extend({
      defaults: {    
        name:'',
        breed:''
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following collection: UsersMod.users_list = Backbone.Collection.extend({ add : function(model) { var duplicate
I have simple user model: var user = Backbone.Model.extend({ initialize: function(){ this.bind(change:auth, function (){
I have the following model: var Soq = Backbone.model.extend({ default:{ 'name': 'something' , 'parents':
I'm just beginning out on Backbone.js. Here's my code. $(function(){ //Backbone Model var Cat
Hello i have this following function: ... var model = $(#carModel); .... model.change(validModel); function
I have the following code in my model: var $name = 'Product'; var $hasMany
For some reason I'm not getting this. (Example model below) If I write: var
i have this in my BlogRepository public IQueryable<Subnus.MVC.Data.Model.Post> GetPosts() { var query = from
#model class Promotion(models.Model): name = models.CharField(max_length=200) start_date = models.DateTimeField() end_date = models.DateTimeField() #view def
I have three Models with the associated properties: Links Model: var $belongsTo = array('LinkCategory');

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.