vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
207.71k stars 33.67k forks source link

Cannot add selected attribute to <option> #5580

Closed KevinBatdorf closed 7 years ago

KevinBatdorf commented 7 years ago

Version

2.3.0

Reproduction link

https://jsfiddle.net/kbatdorf/2ggk4ppo/1/

Steps to reproduce

Add a select dropdown and update the selected attribute via a computed property

What is expected?

The selected attribute is added

What is actually happening?

The selected attribute is not being added


I need this because I'm using the DataTables plugin with an option to print the table in CSV format. By default it includes each option in the table so I need to filter out the values that are currently selected and only display those in the CSV table.

Unfortunately, DataTables passes only a string of the html element (which is why I included it in the example) to be edited and since the selected attribute isn't being added on, I cannot determine which is selected.

Thanks

screen shot 2017-05-03 at 3 26 07 am

posva commented 7 years ago

You have to choose one

Next time, please ask questions on the forum or StackOverflow first, thanks 🙂

KevinBatdorf commented 7 years ago

Thanks posva. I'm not sure you understood my issue but I'll try to explain it better on the forum. Have a good one!

KevinBatdorf commented 7 years ago

I solved my problem so I'll just post it here in case someone ends up here looking for an alternative way to solve it using jQuery. It still seems that I should be able to update the attributes in vuejs though but I guess I can't figure it out :D

https://jsfiddle.net/kbatdorf/2ggk4ppo/6/

Thanks again posva!