1

假设我有以下代码:

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不起作用,但这是我对它如何工作的猜测。

4

0 回答 0