我正在寻找有关如何从按钮触发此视图函数insertNewLine的建议(请参阅下面的视图和模板).我猜测可能有更好的方法来构造这段代码.谢谢你的帮助.
// view
App.SearchView = Ember.TextField.extend({
insertNewline: function() {
var value = this.get('value');
if (value) {
App.productsController.search(value);
}
}
});
// template
<script type="text/x-handlebars">
{{view App.SearchView placeholder="search"}}
<button id="search-button" class="btn primary">Search</button>
</script>
Run Code Online (Sandbox Code Playgroud) ember.js ×1