0
votes

sendAction is not working for component. When using component inside view and sending action from component to view.

confirm-dailog.js

    import Ember from 'ember';
    export default Ember.Component.extend({
    actions:{
       closeConfirmDialog:function(){
          this.sendAction('onCancel');
       }
   }

})

confirm-dailog.hbs

<div class="dialog" id="dialog">
   <div class="text">{{text}}</div>
   <div class="button"{{action 'closeConfirmDialog'}}>Cancel</div>
</div>

modal.js

import Ember from 'ember';
export default Ember.View.extend({
   layoutName: 'components/modal-box',
   actions:
   {
       closeDialog:function()
        {   
            console.log('called model closedialog')
        },
   }
})

modal-box.hbs

<div class="dialog" id="dialog">
    {{yield}}
    {{confirm-dialog onCancel="closeDialog" text="Would you like to close the modal"}}
</div>

when i am clicking on cancel button closeConfirmDialog action gets called and from there i am trying to send closeDialog action but its showing error Nothing handled the action 'closeDialog'

here i have added screenshot of ui

Ember : 1.8.1

Ember Data : 1.13.7

Handlebars : 1.3.0

jQuery : 1.11.1

1
Why are you using Ember.View instead of Ember.Component in modal.js?ykaragol
@ykaragol Ember.Component is working. but i have some cases where view is only suitable.dilip kumar
Can you make it a twiddle? Actually we've never had a need for views in our 7 ongoing projects.ykaragol
this.render(name, { into: 'application', outlet: 'modal', view:'common/modal' }); this is the case . i have used viewdilip kumar
At documentation, the view parameter is defined as: "the view associated with the 'post' Route". You can give a template of a route if you want. Do not use Views because of this.ykaragol

1 Answers

-1
votes

Views are removed from Ember 2.0 API. http://emberjs.com/deprecations/v1.x/#toc_ember-view

I would encourage you to replace view with Component. Moreover for your requirement ember-elsewhere addon or ember-modal-dialog would be most suitable.