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

How to add a click handler in a button inside the suggestion item slot ? #228

Open
joelr-cm opened this issue Mar 16, 2022 · 1 comment
Open

Comments

@joelr-cm
Copy link

Hello guys,

I was wondering how to add a button and a click handler to it inside the suggestion item slot

  • vue-autosuggest version: ^2.2.0
  • node version: v12.22.7
  • npm (or yarn) version: 6.14.15

Relevant code or config

<vue-autosuggest 
      class="hello"
      :component-attr-id-autosuggest="'hey'"
      :suggestions="suggestions"
      :inputProps="inputProps"
      :sectionConfigs="sectionConfigs"
      :getSuggestionValue="getSuggestionValue"
		>
    <template slot-scope="{suggestion}">
      <div v-if="suggestion.name == 'hotels'">
        <img :class="{ avatar: true }" :src="suggestion.item.thumbnailUrl"/>
        {{suggestion.item.title}}
      </div>
      <div v-else>
        {{suggestion.item.name}}
      </div>
      <button @click="onDelete">delete</button>     // <============= This click handler doesn't work
    </template>

image

Reproduction sandbox/repository: https://codesandbox.io/s/vueautosuggest-base-forked-ld3h4o?file=/App.vue

Problem description: I was wondering how to add a button and a click handler to it inside the suggestion item slot ? The click handler on the "delete" button in my sample code doesn't work

@gabsi20
Copy link

gabsi20 commented Aug 10, 2022

watch this #168 (comment)

took me ages to find it

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

No branches or pull requests

2 participants