Passing parameters to jQuery .on() method


#1

I am wrapping a jQuery plugin into a component. This plugin listens for a custom event to trigger an action.

The problem is that when I call my action the parameter received is the jQuery event instead of the parameters I am passing in the handlebars helper action.

How can I get this parameter on the action.

Below my code:

common/confirmation-button.js

export default Ember.Component.extend({
      tagName: "button",
      classNameBindings: ['btn-class'],  
      didInsertElement() {
        this._super(...arguments);
        if (this.get('onConfirm')){
          //jQuery implementation
          this.$().on('confirmed.bs.confirmation', this.get('onConfirm'));
        }
      }
    });

parent-view.hbs

...    
{#common/confirmation-button onConfirm=(action 'confirmDelete' account.id)}}
   Delete account
{{/common/confirmation-button}}

parent-component.js

export default Ember.Component.extend({
  account: Ember.computed.alias('model.account_info'),
  actions:{
    confirmDelete(id){

      // I WANT TO ACCESS TO PARAMETERS HERE
     console.log(id)//jQuery event
    }
  }
});

Thanks in advance


#2

{#common/confirmation-button onConfirm=(action ‘confirmDelete’ value=“account.id”)}} Delete account {{/common/confirmation-button}}

using value option, you can try. then tell me if it work


#3

This is the solution I found:

this.$().on(‘confirmed.bs.confirmation’, () => { this.sendAction(‘onConfirm’) });