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

Would be helpful if Selectize was able to reload state of source element #991

Closed
mcavalletto opened this issue Jan 26, 2016 · 4 comments
Closed
Labels

Comments

@mcavalletto
Copy link

Using the jQuery initialization code, you can create a Selectize instance from a source select element or text field.

However, once you've done that, the synchronization after that is is only from Selectize to the corresponding element -- you can not ask the Selectize element to re-load its state from the source element, and it does not monitor the original element for events that would indicate new options have arrived or the selected items have changed.

It seems like it should be feasible to migrate the init_textbox and init_select logic and the corresponding initialization code from the $.fn.selectize function into the Selectize object itself, allowing that code to be re-used later if an external piece of code update the source element (such as a third-party function loading new options into the select) and we wished to update the Selectize control to reflect those changes.

(Suggestion prompted because I am migrating some pages over from Chosen.js to Selectize.js, and this functionality is already present in Chosen.js.)

@joallard
Copy link
Member

I agree completely, I had that impression when reading the source code and thinking about a refactor–break-down that the "initializing a selectize based on element" should be closer to the core. I would certainly be glad to see steps in that direction, those functions being ideally enclosed in a module/object that we'd then mix-in.

@ghost
Copy link

ghost commented May 6, 2018

@mcavalletto, I know this issue is old, but do you remember a workaround for this? also, what are you using right now, still using chosen.js?

@mcavalletto
Copy link
Author

We have removed chosen.js in favor of selectize.js. You can update a selectize widget via API calls, there's just not a single-step "re-initialize from the source element" shortcut — you have to individually add or remove items one at a time.

@risadams
Copy link
Contributor

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.

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

No branches or pull requests

3 participants