eq evaluates always false
See original GitHub issueI 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());
}
}
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Why does "eq?" evaluate to false in the following context but ...
The expression 'expression is an abbreviation for (quote expression) . When the expression is evaluated it evaluates to expression as a data ...
Read more >Eq with Poly object immediately evaulates to False #12873
And is_zero in Poly returns True if the poly is a zero-polynomial, and False if it's not, rather than returning whether it is...
Read more >Why does Equal["string", False] not evaluate to False?
The answer seems to be something to do with strings being treated as symbols in some contexts but not others. For example, Solve...
Read more >Why does condition always evaluate to false? - Jazz Forum
Trying to execute a conditional step - the condition always evaluates as false - why? A sample condition is 1 = 1 ,...
Read more >Condition always evaluates to false - Power Platform Community
Solved: I'm playing with Flow and am trying to get a condition working but it always evaluates to false regardless/ I want the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@typeoneerror - Play around with http://jsbin.com/fidowu/edit?html,output. You will see that the
selected
attribute (what you see in the “Elements” pane in the Chrome DevTools) never updates even if you change which option is selected. This is (roughly) because the attribute is only used for initial render, and from then forward the property is used.As to what @MichielDeMey mentioned, how I’ve handled this in the past was by creating a custom clone of the
eq
helper calledaeq
(Poor naming, but it’s short):https://gist.github.com/krivaten/a7662fea8da50b42e5ff2311643103f3