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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:39:53+00:00 2026-05-29T14:39:53+00:00

I want to display a simple list of languages. class Language extends Backbone.Model defaults:

  • 0

I want to display a simple list of languages.

class Language extends Backbone.Model

    defaults:
        id: 1
        language: 'N/A'

class LanguageList extends Backbone.Collection

    model: Language
    url: '/languages'

languages = new LanguageList

class LanguageListView extends Backbone.View

    el: $ '#here'

    initialize: ->
        _.bindAll @
        @render()

    render: ->
        languages.fetch()
        console.log languages.models

list_view = new LanguageListView

languages.models appears empty, although I checked that the request came in and languages were fetched. Am I missing something?

Thanks.

  • 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-29T14:39:55+00:00Added an answer on May 29, 2026 at 2:39 pm

    The fetch call is asynchronous:

    fetch collection.fetch([options])

    Fetch the default set of models for this collection from the server, resetting the collection when they arrive. The options hash takes success and error callbacks which will be passed (collection, response) as arguments. When the model data returns from the server, the collection will reset.

    The result is that your console.log languages.models is getting called before the languages.fetch() call has gotten anything back from the server.

    So your render should look more like this:

    render: ->
        languages.fetch
            success: -> console.log languages.models
        @ # Render should always return @
    

    That should get you something on the console.

    It would make more sense to call languages.fetch in initialize and bind @render to the collection’s reset event; then you could put things on the page when the collection is ready.

    Also, _.bindAll @ is rarely needed with CoffeeScript. You should create the relevant methods with => instead.

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

Sidebar

Related Questions

I'm using .NET 2.0 with standard controls. I want to display a simple list
I am new to jQuery. I want a simple list. I just want to
I want to display a simple GIF image in a VBox using GTK+ from
I have a simple quiz application and I want display a nice timer /
i want to use facebook's fb:dialog tag to display a simple pop-up form for
I need some simple databinding for a Spinner. I want to display 2 items
I have a Joda-DateTime field in my model and want to display it formatted
I want to put two buttons in listView. public class Imenik extends ListActivity {
We have a scenario where we want to display a list of items and
What i want to do here is simple...display an ivestigators ID and him corresponding

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.