-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
How to load default (selected) values from database #366
Comments
same as #364 |
Oky thanks but I'm surprise there isn't something simpler ! |
I do not think what I have written is the best or elegant way of solving this. Recently I tried to trigger events on the original select and handle it elsewhere. Currently I am reading the Selectize code to see how else can it be adapted. |
Ok for future users, inspired by geordee work (#364) this is my implementation with a multi select field : Place and hidden id field in your edit form :
No need to add options via php code in your edit form :
in your JS, set your selectize options (read comments) :
And before this build the Selectizer module :
In your controller (here I use PHP and Laravel, but it's the same with a RAILS app) you have to return Json for both of your remote URLs.
Many thanks geordee. |
I have updated my question (and closed the ticket). There is a much better way to do it using data-data attribute. |
Yes it's the method I tried in the first place (look at my first post) but it wasn't working for me, maybe because of the "multiple select" context... |
same as mine, it doesn't doesnt fully render the values pulled from the database. Sometimes it displays 2 out of 3 or totally empty. |
I don't fully understand the issue on a skim and whether it still needs resolution, but if it's still something needed, please make a new issue enhancement request and link here. |
Hi,
I read issue #77 but I still doesn't understand how to initialize my selectize select with selected values from database.
JS
HTML :
When I look the generated HTML I found this, it seems correct :
But when I load the page in the browser, these 2 values aren't shown in the selectize field...
The load function works well, because when I start typing something in the field, it shows me results.
Where am I wrong ? Thanks for your help.
The text was updated successfully, but these errors were encountered: