vendredi 21 avril 2017

How to dynamically switch disabled=true/false of an input text inside Ember Component?

I have an Ember component that I want to dynamically disable/ enable. Initially I have:

//template.emblem
= input type="text" disabled=true placeholder="Account Number" class="form-control"

When I have disabled=false, it enables the button again. Now I want to make it dynamic. I thought of creating a simple function that returns true or false inside component.js:

//component.js
export default Ember.Component.extend({
  ...
    disableButton(){
    return true
  },

//template.emblem
  = input type="text" disabled=disableButton placeholder="Account Number" class="form-control"

This disables it. However, when I switch disableButton to return false, it is still disabled.

How can I connect the disabled to a function/ property inside component.js?

The template.emblem and component.js folder hierarchy is:

components
  |-my-awesome-component
    |- template.emblem
    |- component.js




Aucun commentaire:

Enregistrer un commentaire