Giter VIP home page Giter VIP logo

Comments (11)

rwjblue avatar rwjblue commented on July 18, 2024 2

@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.

from ember-truth-helpers.

rwjblue avatar rwjblue commented on July 18, 2024 1

You have discovered the difference between attributes and properties. Welcome to my nightmare.

from ember-truth-helpers.

krivaten avatar krivaten commented on July 18, 2024 1

As to what @MichielDeMey mentioned, how I've handled this in the past was by creating a custom clone of the eq helper called aeq (Poor naming, but it's short):

https://gist.github.com/krivaten/a7662fea8da50b42e5ff2311643103f3

from ember-truth-helpers.

rwjblue avatar rwjblue commented on July 18, 2024

My general guess is that they are of different types, but we would really need a runnable demo to be sure.

from ember-truth-helpers.

MichielDeMey avatar MichielDeMey commented on July 18, 2024

I'm having the same issue.
I ultimately had to convert my integers to strings due to an API discrepancy.

Maybe we should introduce a non strict equality method? (==)

from ember-truth-helpers.

jmurphyau avatar jmurphyau commented on July 18, 2024

I've just added a test case (I'll push it soon so you can see) that demonstrates this works as expected.. Is clientId an integer in the first example? And if so, and if you are using Ember Data, then the ID in your models are being converted to strings automatically..

The following code

[{{eq 3 3}}] [{{eq '3' 3}}] [{{eq 3 '3'}}] [{{eq '3' '3'}}]

Produces the following output

[true] [false] [false] [true]

from ember-truth-helpers.

typeoneerror avatar typeoneerror commented on July 18, 2024

Seeing this in our app w/2.4 as well. I'm not positive it isn't a browser thing. I've got this in there:

  {{#each content as |item|}}
    <option value="{{get item optionValuePath}}" selected={{eq item selection}}>
      {{get item optionLabelPath}}
    </option>
  {{/each}}

And the <option> does indeed select the correct item, but odd thing is: there's no "selected" property when I inspect the element in Chrome and Safari.

With just <option value="{{get item optionValuePath}}">, the select doesn't select that item at all, so it's working, it just doesn't seem to be bound or something?

from ember-truth-helpers.

typeoneerror avatar typeoneerror commented on July 18, 2024
{{#each content as |item|}}
  {{log (eq item selection)}}
{{/each}}

Logs false, true, false, false (true for the selected item). So it appears that eq is working, but the selected prop is not 100% working or something.

from ember-truth-helpers.

typeoneerror avatar typeoneerror commented on July 18, 2024

Even hard-coding in selected={{eq item.id "2"}} selects the correct item but in the HTML, "selected=" attribute is not here. Will see if I can repro in a clean repo.

from ember-truth-helpers.

typeoneerror avatar typeoneerror commented on July 18, 2024

@rwjblue so this isn't really a truth-helpers issue then from the sound of it?

from ember-truth-helpers.

locks avatar locks commented on July 18, 2024

Having read the thread it seems like there is no bug in ember-truth-helpers. Let us forget about attributes v. properties 🧘‍♂️

from ember-truth-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.