Search code examples
javascriptnativescriptnativescript-vuenativescript-plugin

NativeScript Vue RadAutoCompleteTextView programmatically remove all tokens


There's a removeAllTokens method here and I've seen how to trigger another method from the docs, however it is for angular in the docs and I'm not sure how I can call the removeAllTokens method as I'm using NS-Vue.

An insight would be appreciated


Solution

  • You can set an id on your autocomplete element and when you programmatically want to remove all tokens, just use this

    import { Frame } from '@nativescript/core'
    
    const autoCompleteView = Frame.topmost().getViewById('<id of autocomplete view>');
    if (autoCompleteView && typeof autoCompleteView.removeAllTokens === 'function') {
      autoCompleteView.removeAllTokens();
    }