kristianmandrup / gmaps-autocomplete-rails

Google Maps v3 search with jQuery UI Autocomplete, ready for use with Rails asset pipeline
MIT License
73 stars 35 forks source link

Put 'gmaps-output-longitude' and 'gmaps-output-latitude' to hidden field #15

Open mirap opened 8 years ago

mirap commented 8 years ago

Is there any simple way how to put those values into hidden fields? I'm using gmaps-autocomplete-rails in form_for, so it would be quite handy.

kristianmandrup commented 8 years ago

Fork it, fix it, make a PR ;)

kristianmandrup commented 8 years ago

I just merged some pending pull requests and looked into the code. Yes, you can use hidden fields no problem. Nothing in the code dependent on the type of field, only that the input field has a value attribute. If you have any problems, it could be due to the update_ui function using .autocomplete which you can override to fit your needs.

// fill in the UI elements with new position data
function update_ui( address, latLng ) {
  $('#gmaps-input-address').autocomplete("close");
  $('#gmaps-input-address').val(address);
}