ember-truth-helpers icon indicating copy to clipboard operation
ember-truth-helpers copied to clipboard

eq evaluates always false

Open blogcraft opened this issue 8 years ago • 10 comments

I have this demo in Ember 2.4:

{{#each clients as |clientChoice|}}
{{clientId}} - {{clientChoice.id}}
{{eq clientId clientChoice.id}}
<br>
{{/each}}

And I get this evaluation in screen: 4 - 1 false 4 - 3 false 4 - 4 false 4 - 5 false

Why is this happening?

The complete code (I'm working with components): component.hbs:

<select class="form-control" onchange={{action "selectClient" value="target.value"}} id="selcl">
  <option value="" disabled selected>{{title}}</option>
  {{#each clients as |clientChoice|}}
    <option value={{clientChoice.id}} selected={{eq clientId clientChoice.id}}>{{clientChoice.firstName}} {{clientChoice.lastName}}</option>
  {{/each}}
</select>
{{clientId}}
{{#each clients as |clientChoice|}}
<br>
{{clientId}} - {{clientChoice.id}}
{{eq clientId clientChoice.id}}
{{/each}}

component.js

import Ember from 'ember';

export default Ember.Component.extend({
  clientId: Ember.computed('clientId', function() {
    return this.get('clientId');
  }),
  client: null,
  clients: Ember.computed('clients', function() {
    return this.get('clients');
  }),
  actions: {
    selectClient(clientId) {
      this.set('clientId', clientId);
      console.log($("select").val());
    }
  }
});

blogcraft avatar Jun 08 '16 05:06 blogcraft