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
Dynamically Change the Options in Advanced Select #183
Comments
Was just looking for the same thing. My code is pretty simple.
Nothing gets rendered |
I'm able to render dynamic options for Advanced Select: However, I'm unable to use the onChange to set the state, any know know why? Are you sure you imported the PrelineScript according to the documentation? |
@sebastianbilling For the first render, I can render options with a similar code to yours. The problem is updating (adding or removing) options with jQuery or vanilla JS. Let's say I want to update the options of a select based on data retrieved from the server through JSON object. |
Are you using any library or framework like Vue or React?
|
@olegpix Thanks for your answer. I'm using Django (Python), thus I have to stick with jQuery and vanilla JS for updating the options. I tried to replicate your suggested code but unfortunately couldn't translate it to a working jQuery code. |
Hmmm... The code is very similar to React, which is why I thought you were using it. In any case, if you are using vanilla code (without a library), this means that you need to reinitialize the select using this method
or
Hope it helps. |
I really appreciate your help. I did the following steps but still nothing happened in the frontend:
$("select").empty().append("<option value='test'>test</option>")
Thanks in advance. |
I have the same problem. Adding options dynamically to the advanced select, nothing happens in frontend. |
Having the same problem and unable to update the options dynamically. One workaround is to not render the component until the options data is fetched, which isn't very ideal. Hope there will be a fix for this soon. |
It seems that this issue is a bug rather than |
Hey @more-malekpour, updated the label - our team is looking into it. Thanks! |
Hey everyone, we've just released v2.0.3 update with dynamic validation states, the ability to add/remove options and more. Check out some sample demos at https://preline.co/docs/advanced-select.html#dynamic-validation-states After updating, if you are still having any issues, please open a new issue with more details. Thanks! |
I have the same issue even after updating to latest, the select plugin just doesn't detect changes on the |
Hello,
First of all, thanks for this awesome library. I'm trying to dynamically change (add and remove) the options of the advanced select but have had no luck so far with the
HSSelect
methods, such asbuildOption()
. I can easily create/remove options for vanilla HTML with JS, but not working for the Advanced Select plugin.Thanks in advance for your assistance.
The text was updated successfully, but these errors were encountered: