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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:09:42+00:00 2026-06-07T16:09:42+00:00

I have just started using Ember.js framework and I have simple problem. I have

  • 0

I have just started using Ember.js framework and I have simple problem. I have my data initialized as plain JS objects (filled in the template, created by my PHP scripts) and I’d like to transform them to Ember.js objects before the Ember.Application starts (or immediately after it starts, I don’t know the differences yet).

Is such thing possible? If yes, what’s the best approach to do it?

Example:

App.User = Em.Object.extend({
    id: null,
    avatar: "/path/to/default/avatar.jpg",
    name: null,
});
my_data = [
    {"id":1, "name":"John Doe"}, 
    {"id":2, "name":"Barrack Obama", "avatar":"/president/photo.jpg"}
];
App.usersController = Em.ArrayController.create({
    content: [],
    addUser: function(user) { ... },
});

I need something like this:

App.usersController.initialize(my_data);

Edit: There’s one more thing. My data is not exactly in the same format as Ember objects so I need to do some transformation. Just for example, imagine that I have avatar and name wrapped in another object, like this:

{
  "id":2, 
  "info": {
      "name":"Barrack Obama", 
      "avatar":"/president/photo.jpg"
  }
}
  • 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-07T16:09:43+00:00Added an answer on June 7, 2026 at 4:09 pm

    You could make use of the map function to “transform” your array, see http://jsfiddle.net/pangratz666/agp8C/:

    App.usersController = Em.ArrayController.create({
        content: [],
        initWithDataFromServer: function(hash){
            var users = hash.map(function(item){
                return App.User.create({
                    id: item.id,
                    name: item.info.name,
                    avatar: item.info.avatar
                });
            });
            this.pushObjects(users);
        }
    });
    App.usersController.initWithDataFromServer(my_data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started using RSpec and I copied the very simple test on
I have just started using the Data Access Application Block from microsoft. There are
I have just started using Unity and the interception capabilities. I created a prototype
I have just started using core data. I want to setup a pre-populated db.
I have just started using google's Guava collection ( ComparisonChain and Objects ). In
I have just started using Amazon EC2 API in Java. I have created instances
I have just started using MEF and have hit on an early problem. I
I have just started using WPF and am having trouble data binding from the
we have just started using a git account of our Django website project so
I have just started using flexigrid and wanted to use the resource string to

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.