jeudi 11 février 2016

Ember-cli : Ember.computed.and not working

I defined computed properties and a compound one to disable a button when both are true

 senderEmailAddress: '',
 message: '',

 isValid: Ember.computed.match('senderEmailAddress', /^.+@.+\..+$/),
 isNotValid: Ember.computed.not('isValid'),

 isTooShort: Ember.computed.lte('message.length', 4),

 disabled: Ember.computed.and('isNotValid', 'isTooShort'),

the Ember.computed.and does not work ... If I enter a correct senderEmailAddress and no content isValid: true isNotValid : false isTooShort: true Then the button is enabled ! why ? disabled should be true

If there is no email address and content isValid: true isNotValid : false isTooShort: false Then the button is also enabled ! why ? disabled should be true

computed.and should be TRUE only when BOTH properties are TRUE isn't it ?

my contact template

 {{input type="email" value=senderEmailAddress class="form-control" placeholder="Please type your e-mail address." autofocus="autofocus"}}

 {{textarea class="form-control" placeholder="Your message. (At least 5 characters.)" rows="7" value=message}}

<button class="btn btn-primary btn-lg btn-block" disabled={{disabled}} {{action 'sendMessage'}}>Send Message</button>




Aucun commentaire:

Enregistrer un commentaire