vendredi 4 septembre 2015

In Ember check whether a component is passed an action and use it if it is

Lets say I have a component named advanced-input that contains an input such as:

{{input type="text" value=value class="{{class}}" key-down="keyDownAction"}}

In the js for the component I want to fire an action if it is passed to the component, if it isnt then I want to take my own action:

actions: {
  keyDownAction: function() {
    if (checkForActionNamedMyAction) {
      this.sendAction('MyAction');
    }
    else {
      // Provide some default code
    }
  }
}

So if I were to specify

{{advanced-input MyAction="SendAlertToUser"}}

it will go into the if, but If I have

{{advanced-input}}

then it goes into the else? What do I need to check for?




Aucun commentaire:

Enregistrer un commentaire