標籤:blog http 使用 ar java strong sp div on
在已經設定route的情況下,以table為例,可以如下設定,範圍為對應的模版;
App.TableView = Em.View.extend({});App.TableIndexView = Em.View.extend({});
也可以通過如下建立,其獲得的this為所在模版的this;
{{#view InnerView}}......{{/view}}InnerView = Ember.View.extend({});
簡單設定:
- 設定整體的標籤:
- 設定class:
- classNames:[](適合固定值);
- classNameBinds[](這個要通過其他屬性設定或方法返回,適合變值),同樣使用在template設定classname的方法,如 [‘isEnabled:enabled:disabled‘]
- 設定其他attr屬性
設定event方法:設定的方法配置在view內所有的element上;
使用模版:模版當中的書寫格式與html模版相同;
template: Ember.Handlebars.compile(""),
使用didInsertElement:在render和dom載入完之後執行,此外還有其他在不同時機執行的方法
以tables和table為例在不同url跳轉時候的執行:
- x/x -> x/tables: 同時執行tablesIndexView和tablesView;
- x/tables -> x/tables/id1: 只執行 tableview;
- x/tables/id1 -> x/tables/id2 : 都不執行;
- x/tables/id1 -> x/tables: 只執行tablesIndexView;
在x/tables/id1 -> x/tables/id2 之間跳轉的時候,可以在controller中定義一個方法
ember.js:使用筆記5 使用view