我的模型一个表,我希望能够点击我{{action 'edit'}}
这些模型和灰烬的人会知道哪个型号#的{{action 'edit'}}
是英寸Emberjs,目标的模型,不留“/模型”链接
现在我收到此错误:'GET localhost:3000/category/undefined 404(Not Found)'
这是我在'/ categories'路由中的代码。
<tbody>
{{#each}}
<tr class="people-list">
<td>
<input type="checkbox" class="toggle">
{{#if isEdit}}
{{view Ember.TextField valueBinding="Name" name="Name"}}
{{else}}
<label class="category-text">{{#linkTo 'category' this}}{{Name}}{{/linkTo}}</label>
{{/if}}
<img class="table-img" src="images/x.png">
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
</td>
</tr>
{{/each}}
</tbody>
,然后控制器上:
actions: {
edit:function(){
this.set('isEdit', true);
}
}
404当我点击
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
和模型发生
VpcYeoman.Category = DS.Model.extend({
RecordCategoryID:DS.attr('number'),
Name: DS.attr('string'),
ProjectName: DS.attr('string'),
WorkDescription: DS.attr('string'),
workflow: DS.belongsTo('category', {
polymorphic: true
}),
classNameBindings: ['isAdministrator']
});
VpcYeoman.Calendar.FIXTURES = [
{
id: 0,
RecordCategoryID: 0,
Name: "Fire",
ProjectName: "Electra"
},
{
id: 1,
RecordCategoryID: 1,
Name: "Water",
ProjectName: "Nike"
}
];
和router.js
this.resource('categories', { path: '/categories' });
this.resource('category', { path: '/category/:category_id' },function() {
this.route('edit');
});
我不确定是否应该向路由器添加有关“编辑”的任何内容,因为我不希望程序必须更改URL以便专注于特定模型。
夫妇增加,这将是有帮助的:1.您的应用程序映射(404和URL中“未定义”意味着这是一个路由的问题),2。你的模型结构的一个例子,和3 。你究竟在点击/做什么来产生这个错误。 – gravityplanx
你需要在每一个中使用itemcontroller。你可以请创建一个JSFiddle来说明这个问题吗? – Martin
我已经更新了这个问题。我无法为这类问题设置JSFiddle。 –