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.

Pre Select UiSelect

See original GitHub issue

Sorry for all the inquiries but I just don’t understand how this is supposed to be used.

I have 2 UiSelects one is multi the other is not. I want both to be preselected, but the objects that I pass in as selected are not equal to those in the list (they are for good reasons loaded from 2 different places in the app and therefor have different attributes, but text and value are consistent).

                <ui-select
                        name="roles"
                        v-ref:roles
                        label="Roles"
                        :options="roles"
                        :keys="{text: 'en', value: 'id'}"
                        @closed=""
                        validation-rules="required"
                        multiple>
                </ui-select>

                <ui-select
                        name="title"
                        v-ref:title
                        label="Title"
                        :options="titles"
                        :keys="{text: 'en', value: 'id'}"
                        @closed=""
                        validation-rules="required">
                </ui-select>

Right now I pass it as value, as this is the only way I could make it work a little, but not satisfying (the $refs part is due to be changed):

                    this.$refs.title.value     = this.user.title;
                    this.$refs.roles.value     = this.user.roles;

I would like that the UiSelect checks for key.value (here id) for a match and preselect that and preselects all intersect value (or id) between this.$refs.roles and this.user.roles

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JosephusPayecommented, Sep 6, 2016

Yeah, the computed is the same as just passing the user.roles array.

The reason yours doesn’t work is because you have a syntax error on line 6:

Should be computed: { instead of computed() {

1reaction
JosephusPayecommented, Sep 5, 2016

See if this example fits your use case: http://codepen.io/JosephusPaye/pen/VKYQOW?editors=1000

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. <select> <option value="volvo">Volvo</ ...
Read more >
W3Schools Tryit Editor - Pre-selected Option
<p>You can preselect an option with the selected attribute:</p> ​ <form action="/action_page.php"> <label for="cars">Choose a car:</label>
Read more >
How to specify that an option should be pre-selected when the ...
We can pre-select any option by just specifying the selected attribute in its respective option tag.
Read more >
How to preselect a value in a dropdown list of items in HTML ...
With HTML, you can easily create a simple drop down list of items to get user input in HTML forms. A select box...
Read more >
How to pre-select select statements in Laravel - Laracasts
I have a select statement with a large number of options to select. I am retrieving all of the options from my back-end...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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