Last active
December 11, 2015 03:29
-
-
Save afgomez/4538147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputs.each(function(){ | |
var address = $(this), | |
form = address.closest('form'), | |
hiddenCoords = form.find('#coordinates'); | |
// Namespaceamos el evento para quitarlo más adelante | |
form.on('submit.getAddress', function(e){ | |
// Paramos el evento por defecto | |
e.preventDefault(); | |
ShopLocator.geocode(address.val(), function(results){ | |
var coords = results[0].geometry.location.toUrlValue(); | |
coords.done(function(){ | |
hiddenCoords.val( coords ); | |
// QUitamos solo este evento y enviamos el formulario normal | |
form.off('submit.getAddress'); | |
form.submit(); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment