In my SvelteKit project I am using the svelecte package to add selectize-style select inputs. The initial values are passed in via the the data
variable created by svelte's load
function when the page is requested.
<Svelecte id="category"
options={categories}
creatable = true
on:createoption={newCategory}
bind:value={selected}
on:change="{do_something}">
</Svelecte>
Within my <script>
tag in the corresponding +page.svelte
file I have:
let categories = data.categories;
let selected;
function newCategory(c) {
categories.push(c.detail.value);
}
This works fine except when I try to create a new item. The new Item I create appears in the input, but then when I try to change my selection, instead of the item I created, the new option is shown as [object Object]
What am I doing wrong here?