[英]Ember Component Action Not Bubbling
我發現此問題重復,但是我仍然無法復制我所看到的所有示例的結果。 我正在使用一個Ember.component並試圖將其動作冒泡到它的父路由器(我以前也曾嘗試冒泡到控制器)。
這是我的代碼:Search-bar.hbs模板
//------Search-Bar.hbs------//
<button class="btn btn-purple btn-lg" type="button" {{action 'submitSearch'}}>
Search
<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
</button>
搜索欄Component.js
//------Search-Bar.js------//
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
submitSearch() {
this.sendAction('internalAction');
}
})
Parent-Template.hbs
{{inputs/search-bar internalAction='myAction'}}
父Route.js
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
myAction() {
alert('myAction is called');
}
}
});
為什么這不起作用? 我用console.log()來調用它的所有東西,就像我的submitSearch()
動作一樣,但是此后發生的任何事情都不會冒泡給父對象。
代碼本身看起來不錯。 請確保重新檢查您的實際代碼是否有錯別字,以及文件的路徑。 如有必要,您可以在Ember Inspector中查看預期的路徑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.