Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates not working #1692

Closed
donnyv opened this issue Apr 27, 2023 · 4 comments
Closed

Templates not working #1692

donnyv opened this issue Apr 27, 2023 · 4 comments

Comments

@donnyv
Copy link

donnyv commented Apr 27, 2023

I keep going around and around with this and can't get templates working.
When I put the "label" back in it works fine with the built-in options render. But with the templates it only renders json code.

I'm using v 3.0.0-beta esm version

Html

<vuemultiselect class="form-select form-select-no-caret"
                                            v-model="SelectedLocation"
                                            track-by="Id"
                                            placeholder="Start typing to find location"
                                            open-direction="bottom"
                                            :options="LocationOptions"
                                            :options-limit="100"
                                            :limit="20"
                                            :searchable="true"
                                            :hide-selected="false"
                                            :close-on-select="true"
                                            :clear-on-select="false"
                                            :multiple="false"
                                            :loading="isSearchingLocation"
                                            :internal-search="false"
                                            :max-height="300"
                                            :show-no-results="false"
                                            :preserve-search="false"
                                            :allow-empty="true"
                                            :reset-after="false"
                                            v-on:search-change="asyncFind"
                                            v-on:select="onSelectedLocationName">
                                <template slot="singleLabel" slot-scope="props">
                                    <b>{{props.option.LocationName}}</b>
                                    <span>{{props.option.HouseNumStreet}}</span>
                                </template>
                                <template slot="option" slot-scope="props">
                                    <b>{{props.option.LocationName}}</b><br/>
                                    <span>{{props.option.HouseNumStreet}}</span>
                                </template>
                            </vuemultiselect>

Here is a simplified version. Templates still don't work.
https://jsfiddle.net/c2e968g5/

I also tried the new scope options with Vue 3 for slots. But it still doesn't work.

<div id="app" v-cloak>
    <vuemultiselect
                    v-model="value"
                    placeholder="Start typing to find address"
                    open-direction="bottom"
                    :options="options"
                    :options-limit="100"
                    :limit="20"
                    :searchable="true"
                    :hide-selected="false"
                    :close-on-select="true"
                    :clear-on-select="false"
                    :multiple="false"
                    :internal-search="true"
                    :max-height="300"
                    :show-no-results="false"
                    :preserve-search="false"
                    :allow-empty="true"
                    :reset-after="false">
        <template slot="singleLabel"  v-slot="{ name }">
            <span>{{name}}</span>
        </template>
        <template slot="option" v-slot="{ name, last }">
            <b>{{name}}</b>
            <br />
            <span>{{last}}</span>
        </template>
    </vuemultiselect>
</div>
@donnyv
Copy link
Author

donnyv commented Apr 28, 2023

I got this working for option

<template v-slot:option="{ option }">
    <b>{{option.LocationName}}</b>
    <br />
    <span>{{option.HouseNumStreet}}</span>
</template>

But I can't get this working for singleLabel

<template v-slot:singleLabel="{ option }">
    <span>{{option.LocationName}}</span>
</template>

@donnyv
Copy link
Author

donnyv commented May 1, 2023

So I got an answer with my singleLabel slot not working.
https://stackoverflow.com/questions/76130959/i-cant-get-slot-templates-to-work-with-vue-multiselect-3-0-0-beta-1/76131131#76131131

Since more people are going to start using imports and not precompiling. You might want to change all of your pascalCasing to all lowercase.
image

@mattelen
Copy link
Collaborator

mattelen commented May 5, 2023

Thanks for creating an issue @donnyv. We're aware of this (#1680) and a fix is ready for v4 when we get this that stage of the development path

@mattelen mattelen closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
@amchconsult
Copy link

is it a version 4 coming to fix this issue for vue 3?
thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants