mardi 12 décembre 2017

how to provide callback with context in emberjs

I am using jquery to record a keydown event for an app. I need to use this.sendaction inside it. When used, it shows an error "this.send actions is not a function"

Could someone help me with this please. Thanks

here is my code:

import Ember from 'ember';

const {
  Component,
  $,
  run
} = Ember;


export default Component.extend({

  classNames: ['digital-token-menu'],




didInsertElement() {
          this._super(...arguments);
          $(document).on('keydown', this._keydownHandler);
      },

  willDestroyElement() {
      this._super(...arguments);
      $(document).off('keydown', 'document', this._keydownHandler);
  },

  _keydownHandler(e) {
    if(e.keyCode === 8) {
      this.sendAction('onClose');
    }
  },

actions:{




Aucun commentaire:

Enregistrer un commentaire