1
App.Router.map(function() {
this.resource('documents', { path: '/documents' }, function() {
this.route('edit', { path: ':document_id/edit' });
});
this.resource('documentsFiltered', { path: '/documents/:type_id' }, function() {
this.route('edit', { path: ':document_id/edit' });
this.route('new');
});
});
路線,這個控制器基本上過渡到過濾文件灰燼路由器transitionTo嵌套使用參數
App.DocumentsController = Ember.ArrayController.extend({
subview: function(context) {
Ember.run.next(this, function() {
//window.location.hash = '#/documents/'+context.id;
return this.transitionTo('documentsFiltered', context);
});
},
});
我的問題是,當頁面的哈希改變這個代碼工作正常子視圖事件。
但是,當我NOT /對的location.hash位和W /灰燼運行上面的代碼W¯¯本地transitionTo
我得到一個神祕的
Uncaught TypeError: Object [object Object] has no method 'slice'
任何線索?
感謝
UPDATE:
App.DocumentsFilteredRoute = Ember.Route.extend({
model: function(params) {
return App.Document.find({type_id: params.type_id});
},
});
{{#collection contentBinding="documents" tagName="ul" class="content-nav"}}
<li {{action subview this}}>{{this.nameOfType}}</li>
{{/collection}}
如果沒有看到對子視圖()的調用,就無法確切地說出解決方案。但是在這種情況下Ember似乎期待一個陣列。你需要顯示你對subview()的調用和你的DocumentsFilteredRoute的代碼來找到問題。 – mavilein 2013-04-08 21:38:20
這只是一個簡單的香草餘燼路線w /模型定義。 – Everydaypanos 2013-04-08 22:31:58