Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set the value to the control #27

Open
Github743 opened this issue Nov 24, 2021 · 1 comment
Open

Unable to set the value to the control #27

Github743 opened this issue Nov 24, 2021 · 1 comment

Comments

@Github743
Copy link

Github743 commented Nov 24, 2021

I am setting the options as follows where I am not setting the value field is not getting set, can some one help me

function bindDropDown1(data) { $.each(data, function (i, x) { $('#selec1').append(<option value="${x.Id}">${x.Name}</option>); }); }

Also if I would like to select few by default how can I do that

@zarino
Copy link
Member

zarino commented Dec 17, 2021

@Github743 I’m not sure I understand your question fully, but on "selecting a few by default", if your <option> elements have a selected attribute set when you initiate .multiSelect() on them, then multiSelect will honour that, eg:

<select class="fruits" multiple>
  <option value="apple" selected>Apple</option>
  <option value="orange" selected>Orange</option>
  <option value="tomato">Tomato</option>
</select>
<script>
$('.fruits').multiSelect();
</script>

Note that if you add new <option> elements to the <select> after you’ve called .multiSelect() on it, the new additions won’t appear in the multiSelect dropdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants