No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Google Places Autocomplete using Q-Input not working but works with Input

    Framework
    6
    10
    1386
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      avistad last edited by

      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:

      chrome_15qIkyBFYf.png

      chrome_jAeEhXBlY1.png

      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @avistad last edited by metalsadman

        @avistad try using a ref instead of Id on your qinput, and refer to the wrapped inner input. Ie. this.$refs.myQinput.$refs.input or this.$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.

        A 2 Replies Last reply Reply Quote 1
        • A
          avistad @metalsadman last edited by

          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!

          dobbel 1 Reply Last reply Reply Quote 0
          • dobbel
            dobbel @avistad last edited by

            @avistad

            here’s an article about quasar and google places api:
            https://nsrtechx.com/quasar-google-maps-with-places/

            A 1 Reply Last reply Reply Quote 0
            • A
              avistad @dobbel last edited by

              @dobbel Thanks!

              1 Reply Last reply Reply Quote 0
              • A
                avistad @metalsadman last edited by

                @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 or this.$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?

                1 Reply Last reply Reply Quote 0
                • A
                  avistad last edited by avistad

                  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:

                  chrome_6d5rgPfkfT.png

                  1 Reply Last reply Reply Quote 1
                  • N
                    nulele last edited by

                    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;
                    }

                    1 Reply Last reply Reply Quote 0
                    • D
                      diadal last edited by

                      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,
                      ....
                      }
                      
                      1 Reply Last reply Reply Quote 0
                      • A
                        alexmalcova last edited by

                        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/

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post