Replies: 5 comments 2 replies
-
Looks like it should be |
Beta Was this translation helpful? Give feedback.
-
The sync method might be what you're looking for
https://tom-select.js.org/docs/api/#sync
…On Thu, Sep 23, 2021, 06:04 f4xy ***@***.***> wrote:
not working .
tom-select.ts:99 Uncaught (in promise) Error: Tom Select already
initialized on this element
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#211 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH6YRCMAZZCCGEPAKFILPDUDMQXFANCNFSM5EOKBC3A>
.
|
Beta Was this translation helpful? Give feedback.
-
Did you find a solution or are you still using select2? |
Beta Was this translation helpful? Give feedback.
-
I want to give the solution I found.
And then in the component's class i register a listener and declare a function of the event
inside the function i call the dispatchBrowserEvent method to display the success message to browser. And then i add event listener in my blade
Notice that when livewire re-renders the component, it won't initialize the tom select. |
Beta Was this translation helpful? Give feedback.
-
Hi guys I thought I would post an adapted solution I found to this based on the following stack overflow article here I execute the following code AFTER an ajax call has resolved and I have updated the underlying //This is a filter for clearOptions (see docs) to ensure that my initial placeholder option with a value of 0 isn't removed and stays in the same position in the option list (first)
const clearFilter = (option,value) => value == 0;
//Remove the currently selected option
this.tomSelectInstance.clear();
//Clear all of the options that have currently been rendered by tom select in the dropdown
this.tomSelectInstance.clearOptions(clearFilter);
//Syncronise the plugin with the updated element
this.tomSelectInstance.sync();
//Here I set my selected value back to 0, which is my "Blank" placeholder option
this.tomSelectInstance.setValue(0) You can read more on these methods in the Tom Select API docs here: https://tom-select.js.org/docs/api/ Hopefully this is helpful to someone facing similar problems! :-) |
Beta Was this translation helpful? Give feedback.
-
I have a select2 component in my form and I have surrounded the select with a wire:ignore.
The problem I have is if I submit my form and it fails validation the select2 component no longer lets you add or remove items.
The following solves the problem:
How can I use the following code if tom-slecet is used?
But it doesn't work。
Beta Was this translation helpful? Give feedback.
All reactions