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

The Archive Base Latest Questions

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

I’ve just started using Backbone.js. I want to create a Collection and add some

  • 0

I’ve just started using Backbone.js. I want to create a Collection and add some data from an external source.

The data is actually currently in CSV, not JSON, but I could re-render it in JSON if that is going to be a lot easier.

So, two questions:

  1. Where do I bind external data to the Collection? It complains if I don’t specify a url property, but I don’t really have a URL in mind – I was planning to bind data via Ajax.
  2. Should I re-render my data in JSON, rather than CSV, and use the Collection’s url property to load it?

I just tried loading data directly into the Collection, rather than via the url property:

var Cat = Backbone.Model.extend({});
var CatCollection = Backbone.Collection.extend({
    model: Cat
});
var ajaxData = { 'breed' : 'persian' } // simple example of external data
var catCollection = new CatCollection(ajaxData);
catCollection.fetch();

But this gives an error: Uncaught Error: A "url" property or function must be specified.

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

    Either initialize/reset your collection with an array created elsewhere without using the fetch method for your collection

    var ajaxData = [{ 'breed' : 'persian' }]; // Backbone.Collection expects an array
    var catCollection = new CatCollection(ajaxData);
    // catCollection.fetch(); fetch will try to update the data from the server
    

    or use the built-in url/parse to build your models

    var CatCollection = Backbone.Collection.extend({
        model: Cat,
        url: "your ajax source",
        parse: function (csv) {
            //convert your csv in an array of objects
            return csvtoarray;
        },
        fetch: function (options) {
            options = options || {};
            options.dataType = "text";
            return Backbone.Collection.prototype.fetch.call(this, options);
        }
    });
    var catCollection = new CatCollection();
    catCollection.fetch();
    

    Converting your data server-side to JSON will probably be easier than trying to write a CSV parser in JS.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to construct a data frame in an Rcpp function, but when I
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported

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.