question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to preselect for select element

See original GitHub issue

How to set selected attr to <option> element whose value is equal to item.category? Especially when item.category is changed.

<select class="form-control" name="template" v-model="item.category">
            <option v-repeat="templates" value="{{name}}">{{name}}</option>
</select>

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

42reactions
yyx990803commented, Jun 12, 2014
<select class="form-control" name="template" v-model="item.category">
    <option v-repeat="templates"
        selected="{{name == item.category}}"
        value="{{name}}">
        {{name}}
    </option>
</select>
40reactions
ergonomicuscommented, Jul 6, 2017

@nickmessing , you know @cezar62882 actually helped me July 7, 2017?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I set the default value for an HTML <select> element?
The pre-selected option will be displayed first in the drop-down list. Save this answer. Show activity on this post.
Read more >
How to set the default value for an HTML <select> element
The option tag contains the value that would be used when selected. The default value of the select element can be set by...
Read more >
How to preselect a value in a dropdown list of items in HTML ...
You can also preselect a value in dropdown list of items in HTML forms. For that, add selected in the <option> tag for...
Read more >
HTML option selected Attribute - W3Schools
The selected attribute is a boolean attribute. When present, it specifies that an option should be pre-selected when the page loads. The pre-selected...
Read more >
<select>: The HTML Select element - HTML - MDN Web Docs
If no value attribute is included, the value defaults to the text contained inside the element. You can include a selected attribute on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found