Skip to content

Instantly share code, notes, and snippets.

@ef4
Last active October 7, 2021 09:41
Show Gist options
  • Select an option

  • Save ef4/8367f996eb7b57d1f7a5 to your computer and use it in GitHub Desktop.

Select an option

Save ef4/8367f996eb7b57d1f7a5 to your computer and use it in GitHub Desktop.
Goodbye old Select View
<select onchange={{action (mut vehicle) value="target.value"}}>
{{#each vehicles key="@item" as |vehicleChoice|}}
<option value={{vehicleChoice}} selected={{eq vehicle vehicleChoice}}>{{vehicleChoice}}</option>
{{/each}}
</select>
@ZackMattor

Copy link
Copy Markdown

Trying to use this example... but i don't think the eq is working for me.. in that example i tried testing it by making it the text in the select box (both the values seem to be the same but it never triggers that they are equal)

https://gist.github.com/Criten/cb0c886ab0deb4f4ee7a/edit

@ZackMattor

Copy link
Copy Markdown

It was my bad! my menuable_id was numeric... so i just changed it to a string and it worked. It should work for me because all ids within ember are strings anyways....

@krivaten

Copy link
Copy Markdown

Haven't tried this out on my end yet, but was just curious. If target.value is already set, will it automatically select the value when the view renders?

@elbeezi

elbeezi commented Sep 10, 2015

Copy link
Copy Markdown

@jkgisme:

DEPRECATION: Using '@guid' with the {{each}} helper, is deprecated. Switch to '@identity' or remove 'key=' from your template.

(Ember 1.13.6)

@shayanypn

shayanypn commented Dec 14, 2016

Copy link
Copy Markdown

amazing job. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment