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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:58:36+00:00 2026-05-31T01:58:36+00:00

I feel like I’ve been in this problem before, but this is different than

  • 0

I feel like I’ve been in this problem before, but this is different than other times.

I have a collection of events and need to iterate over them .

I build my collection

MyApp.Collections.UserEvents = Backbone.Collections.extend({
    model: MyApp.Models.Event,
    url: 'user_events/' + User.id,
    initialize: function() {
    }
});

MyApp.Models.Event = Backbone.Model.extend({});

I fetch the collection in my router, and then get the view

MyApp.userEvents = new MyApp.Collections.UserEvents();
MyApp.userEvents.fetch({
    success: function() {
        MyApp.UserEvents.trigger(new MyApp.Views.UserEvents);
    }
});

in the view I try to iterate through the events

MyApp.Views.UserEvents = Backbone.Views.extend({
    el: 'div#user_events',
    initialize: function() {
        user_events = MyApp.userEvents.models;
        console.log(user_events);
        this.render();
    },
    render: function() {
        user_events.each(this.add);
    },
    add: function(event) {
        console.log(event)
    }
});

in my console I get

[d, d, d, d, d, d, d, d, d, d, d, d, d, d]

UserEvents.js:16Uncaught TypeError: Object [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] has no method 'each'

So the way I’m seeing it, I’ve got an array of the events, but for some reason I can’t get each one of the events by iterating over them.

  • 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-31T01:58:37+00:00Added an answer on May 31, 2026 at 1:58 am

    The problem is that you’re calling the each function on MyApp.userEvents.models which is a raw javascript array, and therefore does not have an each function. You should call the each function on the collection itself, like so:

    MyApp.userEvents.each( this.add );
    

    Or if you really want to use the array rather than the collection object, you could use Underscore.js directly:

    _.each( user_events, this.add, this );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this one has been asked before, but I'm unable to find
I feel like I should know this, but I haven't been able to figure
I feel like I should know this but I've been stumped for hours now
I feel like I'm missing something here, but I have this datagrid which when
I feel like this should have a simple answer, but I can't find it.
I feel like a bit of a newbie posting this, but anyway: I have
I feel like i've done this a ton of times, but i can't for
I feel like this will end in a facepalm moment but I've been banging
I feel like this is a dumb question and I'm missing something, but I
I feel like an idiot for asking this but what would a regular expression

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.