'Open IonSelect Programatically in Ionic-Vue App
We have an Ionic-Vue App (Ionic 6 and Vue 3) and try to open an IonSelect programmatically. We tried using a ref like this:
<ion-select ref="mySelect" placeholder="something" v-model="selectedIndex">
<ion-select-option :value="1">One</ion-select-option>
<ion-select-option :value="2">Two</ion-select-option>
</ion-select>
and we can indeed access it like this:
myMethod(){
console.log(this.$refs.mySelect);
}
but we cannot figure out any way to open it. According to the ionic documentation [1] there should be an open() method, but
this.$refs.mySelect.open()
crashes with "... is not a function" so this does not seem to cut it. Any help is appreciated.
[1] https://ionicframework.com/docs/api/select#methods
UPDATE:
Found it. In case someone is looking for this, access the ion-select via
this.$refs.mySelect.$el.open();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
