Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Select Item with Ajax is removing Options #1549

Open

Description

@mcarpinter

I did:

  • [x ] Search for if my issue has already been submitted
  • [x ] Make sure I'm reporting something precise that needs to be fixed
  • [x ] Give my issue a descriptive and concise title
  • 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

I have a selectize dropdown that is loaded with Ajax at document ready. The options are well added, and can be selected by user.
But I have another function that loads the already selected option via another ajax when the modal (where the dropdown is) is shown, and after the options are loaded. But in doing so, all the options are removed from the dropdown.

I tried from the console this line:
jQuery('.targetSel.responsible').selectize()[0].selectize.addItem(912);
The idea was to select the corresponding option (that is the right value of one option of the dropwdown).

Steps to reproduce:

  1. Add options with AJAX at jQuery(document).ready()
  2. Open a modal that must have the dropdown
  3. Call a function where the modal is opened that uses .addItem() method to select the already saved items

Expected result:
The items saved on database are selected based on value

Actual result:
The options are removed

Activity

  1. github-actions commented on Jan 1, 2021

    @github-actions
    Contributor

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

  2. mcarpinter commented on Jan 4, 2021

    @mcarpinter
    Author

    Any news or ideas on this?

  3. added
    pending reviewThis issue was closed as stale; since then additional review has been requested.
    and removed on Jan 4, 2021
  4. risadams commented on Jan 4, 2021

    @risadams
    Contributor

    My apologies, I haven't been able to set up a demo yet to reproduce this.
    If you are able to give us a codepen that would be great, otherwise it may take some time before I can take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending reviewThis issue was closed as stale; since then additional review has been requested.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions