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

  • Home
  • SEARCH
  • 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 8781583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:20:30+00:00 2026-06-13T20:20:30+00:00

Seem to have an issue with bindings when accessing an associated DS.model to DS.model

  • 0

Seem to have an issue with bindings when accessing an associated DS.model to DS.model array.firstObject. So the path in the fiddle below is App.person.parties.firstObject but it doesn’t seem to bind properly. App.person.parties is bound OK and can be used in the outlet but firstObject never seems to work. Any ideas?

Also I don’t think this is the best approach for nextParty – if anyone could offer some advice on how to structure this it would be much appreciated!

http://jsfiddle.net/mJ7q7/5/

JS: –

/* Flip this switch to compare. You should see 'Ember party' appear after 2s when it works */
var works = true;

window.App = Em.Application.create({

    ready: function() {            
        App.set('person', App.store.find(App.Person, 1));                        
    },

    ApplicationView: Em.View.extend({templateName: 'application'}),
    ApplicationController: Em.Controller.extend(),

    Router: Em.Router.extend({

        root: Em.Route.extend({

            index: Em.Route.extend({

                route: '/',
                connectOutlets: function(router, context) {

                    router.get('applicationController').connectOutlet('dashboard', App.get('person'));
                    router.get('dashboardController').connectOutlet('nextParty', 'party',
                        App.get('person.nextParty')
                    );
                }
            })
        })
    }),

    DashboardController: Em.Controller.extend({}),

    DashboardView: Em.View.extend({
        templateName: 'dashboard'
    }),

    PartyController: Em.Controller.extend({}),
    PartyView: Em.View.extend({
        templateName: 'party'
    }),


    Party: DS.Model.extend({
        name: DS.attr('string') 
    }),


    Person: DS.Model.extend({
        firstName: DS.attr('string'),
        lastName: DS.attr('string'),
        parties: DS.hasMany('App.Party'),

        nextParty: function() { return this.get('parties.firstObject'); }.property('parties.firstObject')
    }),




    store: DS.Store.create({
        revision: 7,
        adapter: DS.Adapter.create({

            find: function(store, type, id) {



                if (type == 'App.Person') {

                    if (works) {

                         store.load(type, id, {
                            id: 1,
                            firstName: 'John',
                            lastName: 'Jackson',
                            parties: [99]   
                        });

                    } else {

                        setTimeout(function() {
                            store.load(type, id, {
                                id: 1,
                                firstName: 'John',
                                lastName: 'Jackson',
                                parties: [99]   
                            });
                        }, 1000);

                    }

                }
                if (type == 'App.Party') {
                    setTimeout(function() {
                        store.load(type, id, {
                            id: 99,
                            name: 'Ember party'  
                        });  
                    }, 2000);                            
                }
            }
        })
    })

});

Templates: –

<script type="text/x-handlebars" data-template-name="application">
    <h1>Party app</h1>
    {{outlet}}
</script>

<script type="text/x-handlebars" data-template-name="dashboard">
    <h2>Hi {{content.firstName}} {{content.lastName}}</h2>
    <h3>Next party</h3>
    {{outlet nextParty}}
</script>

<script type="text/x-handlebars" data-template-name="party">

    {{content.name}}

</script>    ​  ​
  • 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-13T20:20:32+00:00Added an answer on June 13, 2026 at 8:20 pm

    The firstObject and lastObject properties are not bindable. You can circumvent it by creating a computed property:

    myFirstObject: function() {
      return this.get('content.firstObject');
    }.property('content.[]')
    

    See here.

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

Sidebar

Related Questions

I seem to have an issue with connecting to an embedded FireBird database from
I seem to have an issue where with jQuery Grid (jqGrid) if I have
i have an issue doing toggleClass it doesn't seem to work properly. the image
I have a slight issue where I can't seem to select a User Control
I have this chronic issue with iPhone UI development where views sometimes seem to
OK so I have an xslt issue that I cannot seem to solve. This
I have been researching this issue pretty extensively and cannot seem to find an
I seem to have an issue. I wanted to add some additional config info
I have an issue and I can't seem to either find the answer here
I seem to have a problem passing some strings on from one form 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.