Google Places Autocomplete using Q-Input not working but works with Input
-
I am trying to use the Google Places Autocomplete API. I cannot get q-input to do the autocomplete. But if I use input it works. The screenshots clearly the outcomes on the two elements.
How can I make q-input work like input without installing anything new?The code used is:
<input type="text" placeholder="Enter your address" id="autocomplete" /> <q-input type="text" placeholder="Enter your address" id="autocomplete" />
mounted () { const input = document.getElementById("autocomplete") as HTMLInputElement; const autocomplete = new google.maps.places.Autocomplete(input); },
And in index.template.html
<script defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDp6_pFytAjg4BA83uaNTqhBs6LSHpu488&libraries=places&callback=initMap"> </script>
Screenshots 1 and 2:
-
@avistad try using a ref instead of Id on your qinput, and refer to the wrapped inner input. Ie.
this.$refs.myQinput.$refs.input
orthis.$refs.myQinput.$el.$refs.input
, can’t test atm, but something along those lines, or just simply console.log your qinput’s refs and check the object to see the ref of the wrapped native html input in the node. -
Thanks @metalsadman . I feel a bit embarrassed to say this but I didnt fully grasp the solution you suggested. I am actually new to both VueJS and Quasar.
So what I understood is I should try to console.log(this.$refs.myQinput.$refs) and then find which object is referenced and use “ref” to point to that?
(I dont know what “ref” is but I will read up about it)
Thanks a lot again! -
here’s an article about quasar and google places api:
https://nsrtechx.com/quasar-google-maps-with-places/ -
@dobbel Thanks!
-
@metalsadman said in Google Places Autocomplete using Q-Input not working but works with Input:
@avistad try using a ref instead of Id on your qinput, and refer to the wrapped inner input. Ie.
this.$refs.myQinput.$refs.input
orthis.$refs.myQinput.$el.$refs.input
, can’t test atm, but something along those lines, or just simply console.log your qinput’s refs and check the object to see the ref of the wrapped native html input in the node.Hey metalsadman - Your solution worked !!! Thanks a lot ! Use of $ref was new to me. I have edited the post to show the solution I implemented. But how did you know that ref would work?
-
This is solved now. Thanks to @metalsadman !
---- solution ----
I modified q-input thus:<q-input type="text" placeholder="Enter your address" id="Qautocomplete" ref="Qautocomplete" @keypress="autocompleteLocation" />
and under scripts:
autocompleteLocation () { const input = document.getElementById(this.$refs.Qautocomplete.$refs.input.id) as HTMLInputElement; const autocomplete = new google.maps.places.Autocomplete(input); },
How the Q-Input element works now:
-
For anybody has trouble showing the dropdown list on cordova app, the problem for me was the css. I solved with this instruction:
.pac-container {
z-index: 9999 !important;
} -
incase you looking for v2 with vue3
const pickup = ref<QInput | null>(null);
<q-input class="full-width" required ref="pickup" type="text" dense label="Enter Pickup Location" v-model="form.pickup" />
let input = pickup.value.getNativeElement() as unknown as HTMLInputElement; return { pickup, .... }
-
Go to the Balance of Gift Cards webpage on the website of Target website. Type in your fifteen-digit gift card number in the first field (you will find this number beneath the barcodehttps://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalance/
https://sites.google.com/ledgercomstarts.com/ledgercomstarts/
https://sites.google.com/venmologinus.com/venmologins/
https://sites.google.com/view/venmol0gin/
https://sites.google.com/view/walmartgiftcardbalancecheckk/
https://sites.google.com/view/url-amazon-com-redeem/
https://sites.google.com/view/targetgiftcardbalancee/
https://sites.google.com/view/vanillagiftcardbalancee/
https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalances/
https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalance/
https://sites.google.com/vanillaegiftcardbalance.com/vanillaegiftcardbalance/
https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalancecheck/
https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalances/
https://sites.google.com/targetgiftcardsbalance.com/targetcomcheckbalance/
https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalancee/
https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalancecheck/
https://sites.google.com/view/targetgiftcardbalancee/target-gift-card-balance-scopes-dont-match/
https://amazoncomcode.onepage.website/
https://sites.google.com/view/spectrumemailloginn/
https://sites.google.com/view/ebaycustomerservicee/
https://sites.google.com/ledgercomstarts.com/ledgercomstart/
https://sites.google.com/view/dunkindonutsgiftcardbalances/
https://sites.google.com/view/amazoncomredeemgift/