orchidjs / tom-select

Tom Select is a lightweight (~16kb gzipped) hybrid of a textbox and select box. Forked from selectize.js to provide a framework agnostic autocomplete widget with native-feeling keyboard navigation. Useful for tagging, contact lists, etc.
https://tom-select.js.org
Apache License 2.0
1.61k stars 120 forks source link

Event doesn't work with more than one tomselect in the component #604

Closed robinhodemorais closed 10 months ago

robinhodemorais commented 1 year ago

hello, I'm using tomselect with vuejs3 and I realized that when I use more than one tomselect in the same component and use the dropdown_close and item_remove events, the tomselect that was not used stops working these events, so I can't capture the moment of the user's action and perform a new report query and make it more dynamic for user navigation, how can I resolve this situation?


            <TomSelect
              v-model="filtroEmpPedido"
              class="w-full"
              refKey="tomSelectEmpPedido"
              id="tomSelectEmpPedido"
              multiple
              :options="{
                plugins: {
                  remove_button: {
                    title: 'Remover',
                  },
                  clear_button: {
                    title: 'Remover Todos',
                  },
                },
              }"
            >
              <option v-for="item in empresapedido" :key="item" :value="item.cd_emppedido">
                {{ item.ds_empresa }}
              </option>
            </TomSelect>
.....
  const tomSelectTransp = ref();
  provide('bind[tomSelectTransp]', (el) => {
    tomSelectTransp.value = el;
  });
......
  const tomSelectEmpPedido = ref();
  provide('bind[tomSelectEmpPedido]', (el) => {
    tomSelectEmpPedido.value = el;
  });
.....
    tomSelectTransp.value.TomSelect.on('dropdown_close', () => {
      rastreio();
    });
    tomSelectTransp.value.TomSelect.on('item_remove', () => {
       rastreio();
    });
....
tomSelectEmpPedido.value.TomSelect.on('dropdown_close', () => {
      rastreio();
    });
    tomSelectEmpPedido.value.TomSelect.on('item_remove', () => {
      rastreio();
    });
github-actions[bot] commented 10 months ago

This issue has not been active in 120 days and has been marked "stale". Remove stale label or comment or this will be closed in 15 days