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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:54:12+00:00 2026-05-24T18:54:12+00:00

I got fully stuck truing to understand how should I work with models and

  • 0

I got fully stuck truing to understand how should I work with models and collections. Data is fetching from server into collection but then I do not know how to access this data in view to use it while rendering

here is my code:

ImmoObject = Backbone.Model.extend();

Realty = Backbone.Collection.extend({
    model: ImmoObject,
    url: 'getall',

    initialize: function(){
        this.fetch();
    }
});

Application = Backbone.Router.extend({
    _realty: null,
    _view: null,
    routes: {
        "": "index",
        //"details": "details"
    },

    initialize: function(){
        this._realty = new Realty();
        if (this._view === null){
            this._view = new StartPage({collection: this._realty});
        }
    },

say, each ImmoObject have name. how I can go through all elements in collection (while rendering view) and output their names? Can I do something like this in StartPage.render()?

$.each(this.collection, function(k, v){
console.log(v.name);
})
  • 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-24T18:54:13+00:00Added an answer on May 24, 2026 at 6:54 pm

    You can use the each method of underscore.js :

    StartPage = Backbone.View.extend({
      el: $("#ul-immo-list"),
    
      initialize: function() {
        _.bindAll(this, "render");
        this.collection.bind('reset', this.render);
      },
      ...
      render: function() {
        this.collection.each(function(immoObject) {
          console.log(immoObject.name);
          this.el.append("<li>" + immoObject.name + "</li>")
        }
      }
    });
    

    And in your router :

    Application = Backbone.Router.extend({
      _realty: null,
      _view: null,
      routes: {
        "": "index",
      },
    
      initialize: function(){
        this._realty = new Realty();
        if (this._view === null){
          this._view = new StartPage({collection: this._realty});
        }
        this._realty.fetch(); 
      },
    });
    

    this._realty.fetch(); will fire a reset event on the collection, which will re-render the the StartPage view.

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

Sidebar

Related Questions

I've got a table ItemValue full of data on a SQL 2005 Server running
I've been testing my application and got stuck into error that does not seem
I've got a website that I'd like to pull data from and it's really
I have got a basic server-side Erlang app (not fully OTP'd yet) which I
I've got two branches that are fully merged together. However, after the merge is
If I've got a variable that contains the fully-qualified name of a file (for
I've got eclipse workspaces for my full time job and my home test work
I have a home page activity that I got from an example, which works
I'm stuck on the following problem and would like to know if you got
I just got this error message: ... from c:/ruby/lib/ruby/gems/1.8/gems/... ... 10 levels... from c:/ruby/lib/ruby/gems/1.8/gems/...

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.