Skip to content

Select Item with Ajax is removing Options #1549

Open
@mcarpinter

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

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