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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:50:43+00:00 2026-06-18T02:50:43+00:00

So I have an Ember Object: App.User = Ember.Object.extend({ firstName: null, lastName: null, dob:

  • 0

So I have an Ember Object:

App.User = Ember.Object.extend({
    firstName: null, 
    lastName: null, 
    dob: Ember.Object.create({
        day: null,
        month: null,
        year: null,
        display: function () {
            var self = this,
            day = (self.get('day') < 10 ? "0" : "") + self.get('day'),
            month = (self.get('month') < 10 ? "0" : "") + self.get('month'),
            year = self.get('year');

            return day + '/' + month + '/' + year;
        }.property('day', 'month', 'year')
    })
});

And on my Controller – I am creating a version of the object – which is then bound to by a form:

App.IndexController = Em.ArrayController.extend({
    user: App.User.create()
});

However – for some reason, whenever I try and get the dob.display computer property within my controller or in my view, I just get an object returned.

this.get('user.dob.display')

{{user.dob.display}}

Any ideas how to make sure it returns a string? This was working up until a couple of days ago when I updated from 1.0.0-pre2 to 1.0.0-pre4.

  • 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-18T02:50:44+00:00Added an answer on June 18, 2026 at 2:50 am

    You should not use create, but createWithMixins. This is the only way to define computed properties on object creation:

    dob: Ember.Object.createWithMixins({
        day: null,
        month: null,
        year: null,
        display: function () {
            day = (this.get('day') < 10 ? "0" : "") + this.get('day'),
            month = (this.get('month') < 10 ? "0" : "") + this.get('month'),
            year = this.get('year');
    
            return day + '/' + month + '/' + year;
        }.property('day', 'month', 'year')
    })
    

    One remark: when setting properties in extend methods, each instance share the same object.
    If you do not know that, go read “Understanding Ember.Object” article written by Dan Gebhardt (this article could be a little bit outdated, but the idea is still the same).

    Consequently, here, you have:

    var user1 = App.User.create().get("dob").set("year", 1988);
    var user2 = App.User.create();
    console.log(user2.get("dob.year")); // => 1988
    

    If you want to define objects that are different between instances, you have to override the init method like this:

    App.User = Ember.Object.extend({
        init: function() {
            this._super(); // do not forget that
            this.set('dob', Ember.Object.createWithMixins({
                // [code ommitted]
            }));
        }
    });
    

    But I suggest you to create a model dob instead of just create it each time you create a user.

    You can try this in a JSFiddle.

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

Sidebar

Related Questions

Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
So I have an object of ArrayProxy kind var App = Ember.Application.create(); App.car =
I have an ember.js model and controller setup like so: //model App.Order = Ember.Object.extend({
I have the following StateManager: Lead.StateManager = Ember.StateManager.extend initialState: 'notParsing' notParsing: Ember.State.create startParsing: (manager,
I have an ember.js Object that overrides the create method so I can pass
I have the following ember.js code: app.js: Game = Ember.Application.create({ ready: function() { Game.gameController.getChallenge();
I have the following controller which contains a view: Lead.Controllers.UrlSearch = Ember.Object.extend init: ->
If I have the following: var ObjectA = Ember.Object.extend({ init: function() { this._super(); document.write('init
I have an array of Ember.Object s which is displayed by Handlebars {{#each}} helper
It is possible to have whitespace in an Ember.Object 's field name, but how

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.