Replies: 3 comments 10 replies
-
Beta Was this translation helpful? Give feedback.
-
@jgreywolf yeah I'm not sure where you pulled your code sample above from, this is not how Listbox components works. Check the official documentation page here: https://www.skeleton.dev/components/listboxes You'll see multiple previews on the page, like so: Tapping the If you're trying to monitor the state of multiple selected list items, then you'll want to use the "Multiple Selection" example here: First you define an array that contains the values you wish to be highlighted on load. If you want none highlighted on load then provide an empty array: // pre-populated on load
let valueMultiple: string[] = ['books', 'movies'];
// empty on load
// let valueMultiple: string[] = [];
Then construct your template using the Listbox and ListBoxItem Item parent/child components as follows: <ListBox multiple>
<ListBoxItem bind:group={valueMultiple} name="medium" value="books">Books</ListBoxItem>
<ListBoxItem bind:group={valueMultiple} name="medium" value="movies">Movies</ListBoxItem>
<ListBoxItem bind:group={valueMultiple} name="medium" value="tv">TV</ListBoxItem>
</ListBox> You'll note the prop names like If you need to loop through and generate ListBoxItem from a dynamic source, such as an array of data. You can do so as follows: let mediumList = ['books', 'movies', 'tv'];
let valueMultiple: string[] = []; <ListBox multiple>
{#each mediumList as m}
<ListBoxItem bind:group={valueMultiple} name="medium" value={m}>{m}</ListBoxItem>
{/each}
</ListBox> But note how ListBox always wraps the iterated ListBoxItem components here. And again |
Beta Was this translation helpful? Give feedback.
-
It just shows an empty array ([]) I created a click event on a button so that I could step through debugger and check the value after select, and it is the same. Also, no errors in browser console |
Beta Was this translation helpful? Give feedback.
-
We are using SkeletonUI in a sveltekit application. We are using skeleton components in other locations of our app, and those are all working great. However, I am super frustrated, because I keep thinking what I want to do should be easy - but the solution is just eluding me
Right now all I want to do is to get the selected items from a listbox. The end goal is to be able to move items between two listboxes.
Below is the code being used to render the listbox:
In my ts code I am using the orgMembersListbox variable to hold the Listbox instance. When I try to access the getSelectedItems function, the error says there is no such function, and if I try to just access the selected property, I get the following:
I have tried setting the options as mentioned in error above, with no change
Is there any real documentation on how to use the components? Other than the super basic info here? https://www.skeleton.dev/components/listboxes
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions