Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

Passing parameters to jQuery .on() method

$
0
0

@ferpintado wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles