如何观察父视图中的属性?

时间:2012-08-24 18:46:38

标签: ember.js

说我有以下代码:

App.PeopleView = Ember.View.extend
({
    templateName: 'people',

    people: Ember.ArrayController.create(
    {
        sortProperties:     ['lastName'],
        sortAscending:      true,
        contentBinding:     Ember.Binding.oneWay('App.Mapper.person')
    }),

    Sort: Ember.View.extend(
    {
        templateName: 'people/sort',

        isAscending: function()
        {
            alert('Here');

            var rootView = this.nearestWithProperty('people');
            return rootView.get('people').get('sortAscending');
        }
        .property('$root.people.sortAscending')
    })
});

我希望能够在property()属性上设置sortAscending,但它属于父视图,我不知道如何引用它。 $root不起作用,但我猜测它是如何工作的。

0 个答案:

没有答案