如何以这样的方式获取按钮的动作:
<script type="text/x-handlebars">
{{#view Ember.Button target="Welcome.booksController" action="loadBooks" id="butt_logger"}}
Load Books
{{/view}}
</script>
在js文件中
$(document).ready( function () {
$('button#butt_logger').click(function(){
console.log("Button was Clicked");
});
});
或
Welcome.booksController = Ember.ArrayController.create({
content: [],
loadBooks: function(){
console.log("Button was Clicked");
//any script
}
});
它们都不起作用(( 我需要建议。 感谢。
答案 0 :(得分:1)
正如您在Ember.Button source code中看到的那样:
Ember.deprecate("Ember.Button is deprecated and will be removed from future releases.
Consider using the {{action}} helper.");
使用{{action}}帮助器,您的模板将如下所示:
<script type="text/x-handlebars">
<button {{action loadBooks target="Welcome.booksController" }} id="butt_logger">Load books</button>
</script>