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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:01:08+00:00 2026-06-16T21:01:08+00:00

I was looking at Emberjs recently and found this useful article written by one

  • 0

I was looking at Emberjs recently and found this useful article written by one of its main contributors: Advice on & Instruction in the Use Of Ember.js

It walked me through an example which fetch a list of user data from a server and render them on screen. I’ll briefly explain how it worked:

  1. The app contacts the server to fetch a list of user data though ajax
    call.
  2. At the end of the ajax call an empty enumerable is returned
    immediately, which is later used as a property of a controller.
  3. Once the ajax call is completed, it populates the enum with data which
    in turns update the controller’s property, and finally triggers an
    automatic re-rendering.

This works fine as long as the list is not revisited. As a user revisit the list, say he/she navigates to another state and then comes back, the logic will be triggered again, fetching the data from server and populates the list. However, the list this time is not empty! Thus we have a list of duplicated data. I would like to resolve this by clearing the content of the list when the ajax call is successful. Below is the code for the ajax call:

allAwesomebergs: [],
fetch: function(){
    $.ajax({
        url: 'https://api.github.com/repos/emberjs/ember.js/contributors',
        dataType: 'jsonp',
        context: this,
        success: function(response) {
            response.data.forEach(function(awesomeberg){
                this.allAwesomebergs.addObject(App.Awesomeberg.create(awesomeberg))
            }, this);
        }
    });
    return this.allAwesomebergs;
},

The above code does not clear the content of the list. I tried adding a line “allAwesomebergs = []” at the beginning of the success function, but what I got was just a blank screen. I thought I may not be doing this correctly, but I looked at the document from Ember and didn’t see anything about clearing the content of an Enumerable.

Thus the question is: what is the easiest way to resolve this duplicate loading issue? Clearing the content before hand seems the most obvious but I can’t make it work.

  • 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-16T21:01:09+00:00Added an answer on June 16, 2026 at 9:01 pm

    You can call clear() before you start adding the new objects. See this documentation.

    New code would be:

    allAwesomebergs: [],
    fetch: function(){
        $.ajax({
            url: 'https://api.github.com/repos/emberjs/ember.js/contributors',
            dataType: 'jsonp',
            context: this,
            success: function(response) {
                this.allAwesomebergs.clear();
                response.data.forEach(function(awesomeberg){
                    this.allAwesomebergs.addObject(App.Awesomeberg.create(awesomeberg))
                }, this);
            }
        });
        return this.allAwesomebergs;
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for best advice on how to do this: I have an insert like
Looking at this array, one can see that only the foo6 value differs from
Looking through this C++ BigInt library and found the BigInt.cpp file. At the top
Looking to do a bit of refactoring... Using NHibernate I have this query currently
Looking for a perl one-liner what will find all words with the next pattern:
Looking for a control that allows to select one text value at a time
I have been looking into Ember.js , and it looks really great, but one
I have a javascript application written with ember.js and am looking to bind an
Looking for a simple blog engine that will support article management. I have standalone
Looking at this css file ( especially the last 5 lines ): #page section

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.