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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:50:04+00:00 2026-06-15T10:50:04+00:00

I plan on doing separate fetches for an individual model and its collection, but

  • 0

I plan on doing separate fetches for an individual model and its collection, but would like the collection to follow the same structure of the model.

Currently, I have separate urls for each, but its crashing on a jQuery error Uncaught TypeError: Cannot read property 'length' of undefined

Should I be doing this a different way? Code is below:

ArticleModel.js

define([
  'underscore',
  'backbone',
], function(_, Backbone) {

  var ArticleModel = Backbone.Model.extend({
        defaults: {},

        url : function() {
            return baseAPIUrl + '/CoreService/GetArticle';
        },

        parse : function(data) {
            console.log(data);

            var articleArray = [];

            $.each(data.Articles, function(i, item) {   
                if (isNotEmpty(item.ScaledImages)) {
                    var Image = item.ScaledImages.ImageUrls[4].Value;
                }

                articleArray = {
                    Id : item.Id,
                    Title : item.Title,
                    FeedTitle : item.FeedTitle,
                    Summary : item.Summary,
                    ImageUrl : Image,
                    Link: item.Link
                };
            });
            return articleArray;
        }
  });

  return ArticleModel;

});

ArticlesCollection.js

define([
  'underscore',
  'backbone',
  'models/article/ArticleModel'
], function(_, Backbone, ArticleModel){

  var ArticlesCollection = Backbone.Collection.extend({

      model: ArticleModel,

      initialize : function(articles, options) {

      },

      url : function() {
        return baseAPIUrl + '/CoreService/GetFollowedMembersArticles';
      },

      parse : function(data) {         
        var articleArray = [];

        $.each(data.Articles, function(i, item) {           
            if (item.ScaledImages != null) {
                var image = item.ScaledImages.ImageUrls[4].Value;
            }

            articleArray.push({
                Id : item.Id,
                Title : item.Title,
                FeedTitle : item.FeedTitle,
                Summary : item.Summary,
                ImageUrl : image,
                Link: item.Link
            });
        });

        return articleArray;
      }     

  });

  return ArticlesCollection;

});
  • 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-15T10:50:05+00:00Added an answer on June 15, 2026 at 10:50 am

    Yes, for your model you would use:

    var Model = Backbone.Model.extend({
       idAttribute: "Id",
       urlRoot: function() {
          return baseAPIUrl + '/CoreService/GetArticle';
       }
    });
    

    You would then instantiate your model like follows:

    var model = new Model({Id: 2});
    model.fetch();
    

    Your api will call the following url then ‘host/CoreService/GetArticle/2’

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

Sidebar

Related Questions

So here is how we plan on doing it in PHP, but we don't
I'm going to be doing some webscraping and my plan is to have something
It's part of an information retrieval thing I'm doing for school. The plan is
I'm doing my best to learn DDD, but I'm unsure about some really basic
I have many short-lived branches in my workflow and I would like them to
The functionality I plan on doing is to insert some form elements depending on
I'm currently having a major brain fart :). My plan was to build a
Does anyone have or know of a good template / plan for doing automated
I plan on doing some experimentation with my math skills in a program I
I plan on using multiple popups on my website. Every popup will be rendered

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.