Remove autocomplete from a text box

1,709 views
Skip to first unread message

Joe Maravillas

unread,
Jun 20, 2011, 12:50:28 PM6/20/11
to google-map...@googlegroups.com
Hello,

I didn't find this in searching through the autocomplete topics. Is there a programmatic way to remove autocomplete from a text box?

I'm trying to handle case where a form changes based on selections in a dropdown and autocomplete is not necessary for some selections.

Thanks!
Joe

Joe Maravillas

unread,
Jun 21, 2011, 4:52:39 PM6/21/11
to google-map...@googlegroups.com
I accomplished what I needed by removing the div with the 'pac-container' class on it when the dropdown value changed.

Something like this:

function dropdown_changed() {
  var val = $('#dropdown').val();

  // make sure autocomplete is set on the necessary fields
  autocomplete_init();

  if (val == 'foo')  {
    // do some stuff
    $('#div1 > .pac-container').remove();
  else if (val == 'bar') {
    // do some stuff
    $('#div2 > .pac-container').remove();
  else {
    // do something else
  }
}




Luke Mahé

unread,
Jun 21, 2011, 10:04:21 PM6/21/11
to google-map...@googlegroups.com
This will probably break in the future. Instead I have filed a bug internally to add a remove/detach method to the autocomplete.

-- Luke



  }
}




--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/ITOBYxVnpB0J.

To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply all
Reply to author
Forward
0 new messages