Selectize.js: Edit form with pre-selected values

Created on 26 Sep 2017  路  6Comments  路  Source: selectize/selectize.js

Hello everyone,

I have an application that uses PHP in the back and the Js on the front along with HTML and CSS (the basics).

And I have a problem with using the selectize for editing a form that makes use of it.

The situation is as follows:
A select with all the permissions of possible users, but in that same form has a variable with the permissions that the user already has, my problem is to already insert these variables as already selected, is loading as a normal select coming only the first item selected, being that Js I just load at the end of HTML and initialize the selectize in my select.

what would be the correct way to implement a select with pre-selected values?

Most helpful comment

I can help if you paste the code, but I can't copy and paste from a screenshot.

All 6 comments

Just make the options like you would a regular select box?

Do you say put the "selected" attribute in the

<select id="select-name" placeholder="Select a person..." multiple>
       <option value="997" SELECTED>Some Already selected option</option>
        <!-- INSERT REST OF OPTIONS HERE -->
</select>
$(function() {
    $('#select-name').selectize();
});

The place I'm filling is this way:
(attached)
select

And my JS
`$(document).ready(function() {
Materialize.updateTextFields();

$('#roles').selectize({
    maxItems: 15
});

});`

I can help if you paste the code, but I can't copy and paste from a screenshot.

closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tr4g picture tr4g  路  4Comments

AndrejVM picture AndrejVM  路  3Comments

fadhilanugrah picture fadhilanugrah  路  4Comments

mparthoens picture mparthoens  路  4Comments

aureole82 picture aureole82  路  3Comments