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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:09:23+00:00 2026-06-10T06:09:23+00:00

Using Ember js, I’ve got a tree-based structure of views, each of which has

  • 0

Using Ember js, I’ve got a tree-based structure of views, each of which has a text box. Entering text in any of the boxes and hitting ‘enter’ should add a ‘reply’ to that view; that is, add another view, indented via <ul>, underneath the original view.

Problem is, when I hit ‘enter’, ember just crashes with an error at line 1 of the ember.js script. Any ideas what the problem could be?

JS Fiddle here: http://jsfiddle.net/TcgJB/1/

  • 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-10T06:09:25+00:00Added an answer on June 10, 2026 at 6:09 am

    Ok, I think ‘ve fixed your fiddle: http://jsfiddle.net/Sly7/hVdab/

    I think the main issue was in

    Bap.Reply = Ember.Object.extend({
      text: null,
      children: [], // don't do that, instead declare it as null, and create
                    // an empty children at instanciation time 
      addReply: function(text) {
        this.get('children').addObject(Bap.Reply.create({text:text, content: []}));
      },
    });
    
    //or an equivalent implementation, if you want each instance to be created with a default empty array:
    
    Bap.Reply = Ember.Object.extend({
      text: null,
      children: null,
    
      //overriding the init method (kind of constructor for Ember's Objects
      init(): function() {
        this._super(); // very important, don't forget it
        this.set('children', []);
      },
    
      addReply: function(text) {
        this.get('children').addObject(Bap.Reply.create({text:text, content: []}));
      },
    });
    

    When you want to declare a class, if it owns an array child, you must declare it as null, and then initialize it to [] at creation time. This is a common gotcha when beginning with ember. In fact, the underlying behavior is that all instances of Bap.Reply will share the same children array.

    So when you add some children into the first one, this may result in a crappy structure, as all children have the same parent, some children have the same children as their siblings, etc… I think after that, Ember is lost when it wants to update the bindings and render the views, and so you encounter unexpected and weird errors.

    By the way, I’ve fixed some minor typos, as class should be camel-cased, in order to respect the Ember Naming convention.

    Here is two usefull links whose go into details:

    • Ember gotchas, 6th paragraph
    • About naming conventions
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Ember 0.9.8.1 and having an issue with nested views not retaining the
I'm building a table cell using two bound ember.js views on data. When I
So I started using EmberJS today. // js/main.js require.config({ baseUrl:'js/', paths:{ ember: 'libs/emberjs/ember-0.9.8.1', text:
Emberjs core has a new router implementation which extends Ember.StateManager. This is the basic
I have a Ember.Select View, using which I can bind an Array of contents
The documentation has an example of using an ArrayController with this template: {{#each MyApp.listController}}
I'm trying to get Ember running with BPM based on these instructions: https://github.com/bpm/bpm/wiki/Using-BPM-with-SproutCore-2.0 Everything
I'm using Ember built from git master. My RouteManager is not complex, but when
I am implementing an application using ember.js and couchdb. I choose ember-resource as database
I am working on converting a Backbone application into an Ember application using Ember

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.