vue-at icon indicating copy to clipboard operation
vue-at copied to clipboard

Is there a callback for when an item is selected?

Open jetlej opened this issue 6 years ago • 6 comments

I need to prevent the default functionality and call another function when an item is selected from the dropdown. Is that possible?

jetlej avatar Jan 12 '19 14:01 jetlej

Seems we need to override the method, via hack or some new feature?

https://github.com/fritx/vue-at/blob/ec002402ab875150558bbcc4f84d5deb3fa87be4/src/At.vue#L161-L164

fritx avatar Jan 12 '19 14:01 fritx

A new feature would be ideal! This seems like it should be a standard hook. No?

jetlej avatar Jan 19 '19 15:01 jetlej

@jetlej seems we already have an @insert event

https://github.com/fritx/vue-at/blob/ec002402ab875150558bbcc4f84d5deb3fa87be4/src/At.vue#L452-L453

fritx avatar Jan 20 '19 04:01 fritx

@fritx - How would I interact with that? Can I cancel the handleInput() somehow so the text isn't inserted?

jetlej avatar Jan 20 '19 22:01 jetlej

~~@jetlej Try the following example ;)~~

<at @insert="handleInsert">
  <your-editor-here>
</at>

handleInsert (item) {
  console.log('inserted', item)
}

fritx avatar Jan 21 '19 06:01 fritx

@jetlej ah, sorry, you wanted to prevent the default one... so that a feature is required.

fritx avatar Jan 21 '19 06:01 fritx