2015-11-10 22 views
0

我有一個應用程序,當做搜索返回一些數據顯示給我的用戶。當我點擊進行搜索時,我收到這個錯誤和動作中的模型對象,不要顯示填充了信息的模型。按照錯誤和代碼。沒有處理的行動Emberjs 2

Uncaught Error: Nothing handled the action 'doSearchBooking'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble. 

組件

export default Ember.Component.extend({ 
    actions: { 
     searchBooking(booking) { 
      console.log('Component - 6', booking); 
      this.sendAction('doSearchBooking', booking); 
      this.set('booking', {}); 
     } 
    } 
}); 

表單組件

<form class="row" > 
    <div class="col-sm-3"> 
      {{input type='text' value=booking.doc1 class='form-control'}} 
    </div> 
    <div class="col-sm-2"> 
      {{input type='text' value=booking.doc2 class='form-control'}} 
    </div> 
    <div class="col-sm-2"> 
     {{input type='text' value=booking.doc3 class='form-control'}} 
     </div> 
     <div class="col-sm-3"> 
      {{input type='text' value=booking.idDoc class='form-control'}} 
     </div> 
     <div class="col-sm-2 btn-form-pesquisa"> 
      <button class="btn btn-primary" {{action 'searchBooking' booking}}>Search</button> 
     </div> 
</form> 

調用組件

{{search-booking booking=model.booking searchBooking='doSearchBooking'}} 

我控制器

export default Ember.Controller.extend({ 
    actions: { 
     doSearchBooking(booking) { 
      console.log('controller - 6'); 
      this.sendAction('searchBooking', booking); 
     } 
    } 
}); 

我的路線

export default Ember.Route.extend({ 
    model() { 
     return Ember.RSVP.hash({ 
      data: this.store.createRecord('booking'), 
      booking: {} 
     }); 
    }, 
    actions: { 
     searchBooking(booking) { 
      let newSearch = this.store.createRecord('booking', { 
       doc1: booking.doc1, 
       doc2: booking.doc2, 
       doc3: booking.doc3, 
       idDoc : booking.idDoc 
      }); 

      newSearch.save(); 
     } 
    } 
}); 

回答

1

的問題是,你傳遞行動組件作爲searchBooking

{{search-booking booking=model.booking searchBooking='doSearchBooking'}} 

但你嘗試將它調用組件爲:

this.sendAction('doSearchBooking', booking); 

請嘗試像這樣調用它:

this.sendAction('searchBooking', booking); 
+0

我更改發送操作和錯誤繼續 – flpms

+0

您確定您的代碼沒有錯字嗎?錯誤的行爲名稱中有空格 - 「doSearch Booking」。 –

+0

我確定,我在Ember github上看到很多問題,與此有關。 – flpms