没有任何处理Emberjs 2的动作 [英] Nothing handled the action Emberjs 2

查看:86
本文介绍了没有任何处理Emberjs 2的动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,当做搜索返回一些数据为我的用户显示。当我点击进行搜索时,我收到此错误和模型对象在操作中,不显示填充信息的模型。跟踪错误和代码。

I have a application when do a search an return some datas to show for my user. When I click to do a search I receive this error and the model object inside the actions, don't show the model with informations filled. Follow error and code.

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();
        }
    }
});


推荐答案

问题是您将操作传递给组件为 searchBooking

The problem is that you pass action to component as searchBooking:

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

但是,您尝试在组件中调用它:

But then you try to call it in component as:

this.sendAction('doSearchBooking', booking);

相反尝试像下面这样调用:

Instead try to invoke it like this:

this.sendAction('searchBooking', booking);

这篇关于没有任何处理Emberjs 2的动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆