【发布时间】:2015-11-12 04:01:41
【问题描述】:
我有以下控制器代码:
var App = Ember.Application.create();
App.DocumentController = Ember.Controller.extend({
actions:{
test:function(){
console.log('test');
}
}
});
这个表格:
div class="form-horizontal form-group form-group-lg row">
<div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-1 col-md-5 col-md-offset-2">
{{input type="text" value=name class="form-control" placeholder="Name of document." autofocus="autofocus"}}
</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-offset-0 col-sm-4 col-md-3">
<button class="btn btn-primary btn-lg btn-block" {{action 'test'}}>Create Document</button>
</div>
</div>
{{#if responseMessage}}
<div class="alert alert-success">{{responseMessage}}</div>
{{/if}}
点击按钮时,调试器输出:
没有处理“firstAction”动作。如果您确实处理了该操作,则此错误可能是由于从控制器中的操作处理程序返回 true 导致该操作冒泡
不知道是什么问题——路由代码:
Router.map(function() {
this.resource( 'index', { path: '/' } );
this.route('decisions');
this.route('teams');
this.route('about');
this.resource("documents",{ path: '/documents' }, function() {
this.route('/show', {path: '/show/:id'});
this.route('/edit', {path: ':id/edit'});
});
});
型号代码:
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('String'),
url: DS.attr('String'),
text: DS.attr('String')
});
我知道 ember 有一个严格的命名约定,但我使用他们教程中的命名约定从 ember-cli 生成了资源(文档)。如何让模板 hbs 代码与控制器对话?
【问题讨论】:
标签: ember.js ember-data ember-cli