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

selectize.destroy does not seem to reset everything correctly #1257

Closed
prtome opened this issue Feb 28, 2017 · 3 comments
Closed

selectize.destroy does not seem to reset everything correctly #1257

prtome opened this issue Feb 28, 2017 · 3 comments

Comments

@prtome
Copy link

prtome commented Feb 28, 2017

I did:

  • [x ] Search for if my issue has already been submitted ---> it might be similar to Destroy method making two options :selected #827
  • [ x] Make sure I'm reporting something precise that needs to be fixed
  • [x ] Give my issue a descriptive and concise title
  • [x ] Create a minimal working example on JsFiddle or Codepen
    (or gave a link to a demo on the Selectize docs)
  • [x ] Indicate precise steps to reproduce in numbers and the result,
    like below

The problem is shown in the following jsfiddle: https://jsfiddle.net/prtome/0cv893cr/10/

Steps to reproduce:

  1. click on the single button, select an option then click on cancel then read the value in the result area (it is what is expected: example "5")
  2. click on the list button, select an option then click on cancel then read the value in the result area (its is what is expected example ["5"] )
  3. click again on the single button, select an option then click on cancel then read the value in the result area (it is NOT what is expected: example ["5"] like with the list version)

I would have expected that after calling cancel, and thus destroying, and recreating the selectize, I would have again the same result with single. It seems like if destroy is not resetting completely the options.
Tests have run on safari and Chrome
Thank you

@dmytro-y-dev
Copy link

dmytro-y-dev commented Aug 25, 2017

I also verified, selectize's event listeners are not being properly detached from jQuery.

When you run $._data(window, 'events') in browser's console, you can find that after going through several pages in our SPA where selectize is embedded, resize events count is rapidly growing.

@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.

@CyrilleHantz
Copy link

CyrilleHantz commented Feb 14, 2024

Issue is still Here in version 0.15.2. Not completed at all.

I found the reason in the code:
Events are linked to "Selectize.count++", instead of an eventual "Selectize.uid++"
But destroy do "--Selectize.count", no need to explain the result on event uid.

You can change the destroy or the setup function as you wish.

Workaround:

require([
    'jquery',
        'selectize'
    ], function ($, selectize) {
        ...
        input_jquery[0].selectize.destroy();
        selectize.count++;
        ...
})

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

4 participants