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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:55:54+00:00 2026-06-15T09:55:54+00:00

i try to fetch a record of a rails-api (same host) into my backbone

  • 0

i try to fetch a record of a rails-api (same host) into my backbone collection. i have the following code:

// Models

App.GeeksModel = Backbone.Model.extend({
  urlRoot: "/geeks",
  idAttribute: "id"
});

// Collections

App.GeeksCollection = Backbone.Collection.extend({
  url: "/geeks",
  model: App.GeeksModel
});

in my router i have the following

// Router

App.GeekRouter = Backbone.Router.extend({
  routes: {
    "": "index"
  },
  initialize: function() {
    console.log("router - init");
  },
  index: function() {
    console.log("route - index");
    var geekCollection = new App.GeeksCollection();
    var mapView = new App.GeeksMapView({ el: $("#foo"), model: geekCollection });
    geekCollection.fetch();
  }
});

when browsing the url, the view loads correctly and at the server i see, that one entry is fetched from the database. but as soon as i check the model length in my view using

this.model.length

the collection is empty… any advice on this?

thanks

EDIT 1:

when changing the index router method to

var mapView = new App.GeeksMapView({ el: $("#map"), collection: geekCollection });

and e.g. check for the collection length in the views intialize method

  ...
  initialize: function() {
    this.render();
    console.log(this.collection.length);
  },
  ...

it retunes 0 as well… so nothing changed!

  • 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-15T09:55:56+00:00Added an answer on June 15, 2026 at 9:55 am

    I believe you want to do collection.length or if accessing from the model – each model holds reference to collection in which it was created model.collection.length – if this is referencing to collection doing just this.length should be enough, if it’s a model then this.collection.length will do it for you.

    Models have no property length so should always be undefined unless you define it yourself.

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

Sidebar

Related Questions

I have two table TABLE_EXAM and TABLE_QUESTION. I fetch record using following code but
I'm try to insert or update db record with following code: Category category =
I fetch record from database using following code. for (LocWiseProfileBeans cn : LocWiseProfile) {
I have the following PHP code: foreach (...) { try { $Object = MyDataMapper::getById(123);
I fetch the Guid of Record using below code in Silverlight Application in CRM.
I'm trying to implement the Active Record Pattern with PHP; I have the following
I try to fetch a float number from a QString using toFloat() method but
I use kohana and when you try to fetch data from database it returns
Started recently, basically every time I try to fetch or commit it gives me
I'm having a little trouble using AmazonCloudWatch to fetch CPU Utilization. When I try

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.