Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple autocomplete fields on the same page does not autocomplete correctly #2

Open
pdsteele opened this issue May 28, 2013 · 8 comments

Comments

@pdsteele
Copy link
Contributor

Hi,

First, I want to say thanks for writing this great gem. It makes using gmaps autocomplete much easier, and gives me better results than other solutions.

I am currently trying to get multiple autocomplete fields on the same page, and by initializing gmaps-autocomplete with different input-field ids, it does work as intended (with respect to showing autocomplete results).

However, if you choose a result and autocomplete, it will also autocomplete all fields that occur after the chosen field (e.g. autocompleting address field 1 will fill address field 2 and 3 with the same results, autocompleting address field 2 will fill address field 3 with the same results, and autocompleting address 3 will result in the expected behavior).

@kristianmandrup
Copy link
Owner

I encourage you to branch off this gem. Then substitute the current JS implementation with a JS class based solution, using coffeescript. This should allow creating multiple instances of the same class and thus solve your issue. Maybe we can work on this as a team ;)

@pdsteele
Copy link
Contributor Author

That would be interesting to do, but I am very new to web development. Any idea of how much time this would take for a novice, and would you be able to point me in the right direction for good resources to learn from?

@kristianmandrup
Copy link
Owner

I just pushed a partial conversion to coffescript using a class to package the functionality. You can help work on it ;)

@kristianmandrup
Copy link
Owner

See the update section in the readme. Check out gmaps-auto-complete.coffee

And http://arcturo.github.io/library/coffeescript/03_classes.html

@pdsteele
Copy link
Contributor Author

Thanks, that was really fast! I've tried using it, but for some reason, I keep getting the error that GmapsCompleter is not defined. I've made sure the file is included in the source, and it compiles to exactly what you have in the assets folder, but for some reason, the method is not being found.

Just to clarify, in order to start it now, should
"$(document).ready ->
new GmapsCompleter()
#GmapsCompleter.autoCompleteInit()
return "
be included in the class coffee file? I am getting meaningful errors this way, but I'm not sure if it will lead to the expected behavior, even when everything else is made to work correctly.

@pdsteele
Copy link
Contributor Author

I got it working. I made a pull request with a couple small changes to the coffeescript (and compiled coffeescript), and an updated readme with instructions on how to use the new class. However, I only tested it with autocomplete, so issues may still exist with the map features.

@shahroon
Copy link

shahroon commented Sep 20, 2017

Any update on using it for multiple input fields? As per General info on this repo

The script is now compiled from Coffeescript and allows you to have multiple fields linked to multiple instances of the GmapsCompleter class on the same page.

It should work, if it is correct then please close this issue.

@kristianmandrup
Copy link
Owner

Please someone re-engineer this class using ES6 classes and modules. Cheers ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants