fritx / vue-at

At.js for Vue.
https://fritx.github.io/vue-at/
MIT License
532 stars 114 forks source link

Is there a callback for when an item is selected? #85

Open jetlej opened 5 years ago

jetlej commented 5 years ago

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

fritx commented 5 years ago

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

jetlej commented 5 years ago

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

fritx commented 5 years ago

@jetlej seems we already have an @insert event

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

jetlej commented 5 years ago

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

fritx commented 5 years ago

@jetlej Try the following example ;)

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

handleInsert (item) {
  console.log('inserted', item)
}
fritx commented 5 years ago

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