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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:25:50+00:00 2026-06-12T23:25:50+00:00

I have just begun learning ember.js, I have followed some tutorials and created a

  • 0

I have just begun learning ember.js, I have followed some tutorials and created a working example here:

App.Track.reopenClass({
    find: function() {
        var tracks = [];

        $.ajax({
            url: 'http://ws.spotify.com/lookup/1/.jsonuri=spotify:album:6J6nlVu4JMveJz0YM9zDgL&extras=track',
            dataType: 'json',
            context: this,
            success: function(data, textStatus, jqXHR) {
                $.each(data.album.tracks, function(index, value) {
                    track_id = value.href.replace("spotify:track:", "");
                    tracks.addObject(App.Track.create(value));
                    // I would rather do something like:
                    // tracks[track_id] = App.Track.create(value)
                });
            }
        })
        return tracks;
    }
});

This function hits an API and loops through the returned data to populate the tracks object (tracks.addObject(App.Track.create(value));) and return it.

Rather than getting an ordinary object back from this function, I would like to get an Enumerable / Array so I can manipulate it with filterProperty or pull out tracks by id (There is a track_id which I would like to use as the array index).

All of my attempts to use an array have broken ember’s magical ability to update the view when the ajax call populates the tracks.

Can anyone modify http://jsfiddle.net/ZEzwn/ to return an Enumerable (preferably an Array) but still update the view automatically?

  • 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-12T23:25:52+00:00Added an answer on June 12, 2026 at 11:25 pm

    As your method already returns an Array (because you have Ember prototype extension enabled), doing:

    var tracks = [];
    

    is equivalent to

    var tracks = Ember.A();
    

    On ajax request success, you’re just populating the array, so you could use Ember.Array methods like filterProperty.

    Just one thing about using id as array key, you really SHOULD NOT, as Ryan Bigg says in its blog:

    However, if the variant’s id is [something a little higher, like] 1,013,589,413, then you start to run into problems.

    In that case, JavaScript would create a one billion, thirteen million, five hundred and eighty-nine thousand, four hundred and fourteen element array. All to store one value in, right at the end.

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

Sidebar

Related Questions

In learning C, I've just begun studying pointers to structures and have some questions.
I have just begun working on a project which uses Mercurial as a version
I have just begun working with the Android SDK and I am having problems
I've just begun learning Silverlight (though I have 3 years C# experience). I'm trying
I've just begun learning Unix and have so far encountered two elementary though difficult
I have just begun learning Python. Eventually I will learn Django, as my goal
So I have just begun learning the Django framework, and I am trying to
I have just begun learning PostScript in order to produce graphics for LaTeX and
I have just begun working on a C# application (using log4net). I'm supposed to
I have just began learning Java programming, I have created a simple game using

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.