My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 3429: Bug: no way to unbind autocomplete
30 people starred this issue and may be notified of changes. Back to list
Status:  Acknowledged
Owner:  [email protected]


Sign in to add a comment
 
Reported by [email protected], Jun 23, 2011
1. use new google.maps.places.Autocomplete(input, options); on textbox
2. No need more autocompletion
3. No API function to unbind event

I'm using two different autocomletion Google or Freebase in two different cases regarding on user input.
So onse binded Google autocompletion it is no possibility to remove it from input, to use other.

*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

Jun 23, 2011
#1 [email protected]
(No comment was entered for this change.)
Labels: -ApiType-PlacesAPI ApiType-Javascript3
Jun 29, 2011
#2 [email protected]
I got the same here too. My workaround is writing the data to a hidden text input though.
Jul 17, 2011
#3 [email protected]
(No comment was entered for this change.)
Status: Acknowledged
Labels: -Type-Defect Type-Enhancement Internal-5039908
Apr 3, 2012
#4 [email protected]
Same problem
I am using same auto complete field in 2 different light box forms and second time it never works.
What to do?? 
Jul 16, 2012
#5 kleppe
Currently, the only way to unbind the autocomplete is by using google.maps.event.clearListeners and remove all "focus", "blur" and "keydown" events and then remove the .pac-container:

    google.maps.event.clearListeners(input, "focus");
    google.maps.event.clearListeners(input, "blur");
    google.maps.event.clearListeners(input, "keydown");

    $(".pac-container").hide();

But I'm afraid this might break if the internal calls change in one of the next API releases.
Jul 30, 2012
#6 [email protected]
(No comment was entered for this change.)
Apr 1, 2014
#7 [email protected]
Hey everybody !
I've found a simple ugly workaround which prevent autocomplete to go further "place_changed" callback, you just need to insert a runtime error and it will stop there.

    google.maps.event.addListener(autocomplete, 'place_changed', function() {
        var place = autocomplete1.getPlace();
        error(); // This is the runtime error, undefined function
    });

I've just tried it with FF, it doesn't stop the listeners, you can still reuse the form for example.
Jun 2, 2014
#8 [email protected]
Is this issue still open?

Apparently 
autocomplete.unbindAll();
removes any listeners added to autocomplete.

google.maps.event.clearInstanceListeners(element);
removes any listeners added to input element.

Not sure if anything else needs to be done for full cleanup.
Jan 19, 2016
#9 [email protected]
Is there any way to get corresponding '.pac-container' to given Autocomplete instance? I am working on angular app and after going back and forth views with such field, multiple '.pac-container' are spammed and left in DOM.
Jan 19, 2016
#10 [email protected]
$scope.$on('$destroy',()=>{
	var instance = document.querySelector('.pac-container');

	autocomplete.unbindAll();
	google.maps.event.clearListeners(autocomplete);

	if(instance){
		instance.parentNode.removeChild(instance);
	}
});
Mar 25, 2016
#11 [email protected]
Non of the solutions above works for me:

* autocomplete.unbindAll() // does not unbind any binging
* $(".pac-container").hide() //not sufficient
* $(".pac-container").remove() //works well if you have only one autocomplete on the page. If you have more, you disable all of them.

My workaround is to remove input element and recreate it again.
Sign in to add a comment

Powered by Google Project Hosting