【发布时间】:2014-07-02 12:39:23
【问题描述】:
我尝试扩展一个组件 (https://github.com/ember-addons/ember-forms),以便在表单控件旁边添加额外的按钮。
想法
开发者将一个额外的属性传递给组件,部分将在表单控件(输入、选择、文本区域)旁边呈现。
问题
它工作正常,但如果我有一些动作的部分,动作不会触发。
JsBin
这里有一个简化的 JsBin 来演示这个问题:http://jsbin.com/pexolude/105/edit
html
<script type="text/x-handlebars">
<h2>Component test</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
{{booh-whaa partial="somebutton"}}
<h3>This partial's action works</h3>
{{partial "somebutton"}}
</script>
<script type="text/x-handlebars" data-template-name='_somebutton'>
<button {{action "booh"}} >Hit me!</button>
</script>
<script type="text/x-handlebars" data-template-name='components/booh-whaa'>
<h3>This is my component</h3>
{{partial partial}}
</script>
JS.
App = Ember.Application.create();
App.IndexController = Ember.Controller.extend({
selectedCategory:null,
actions: {
booh: function() {
alert("booh!");
}
}
});
App.BoohWhaaComponent = Ember.Component.extend({
});
【问题讨论】:
标签: javascript ember.js