私はApp.WidgetView、かなり高価なサードパーティの ui 要素の設定とレンダリングを担当する を持っています。この ui 要素 と呼びましょうwidget。これwidgetにはrefresh()方法があります。を呼び出すrefreshWidget()メソッドを定義しました。App.WidgetViewwidget.refresh()
App.WidgetView = Em.View.extend({
content: null,
widget: null,
init: function () {
this._super();
//initialize widget using content
},
refreshWidget: function () {
this.get('widget').refresh();
}
});
データをプルWidgetViewするループを使用してページにレンダリングされた のリストがあります#eachApp.widgetController
{{#each App.widgetController}}
{{view App.WidgetView contentBinding="this"}}
{{/each}}
今、私はメソッドを用意する必要がありますが、refreshAll()これApp.widgetControllerをきれいに行う方法はあまり知りません。現在、呼び出されるたびに開始して増加するrefresherプロパティがあります。App.widgetController0refreshAll
App.widgetController.reopen({
refresher: 0,
refreshAll: function () {
this.incrementProperty('refresher');
}
});
次に、バインドされてApp.WidgetViewいる aと、変更
時に呼び出すオブザーバーがありますrefresherBindingApp.widgetController.refresherrefreshWidgetrefresher
App.WidgetView.reopenClass({
refresherBinding: 'App.widgetController.refresher',
refresherChanged: function () {
this.refreshWidget();
}.observes('refresher')
});
それは機能しますが、それを行うためのより明確な方法があるかどうか疑問に思っています。