can someone help me out.
http://www.liquidlizard.net/jobs/search <-- on this page I have an input where people can enter a location and when they hit enter or click the submit button I run a function to geocode the location they've typed in, update some hidden lat lng inputs and only then submit the form.
Trouble is, although it works fine when you click the button, for some reason when you hit return (although the same code happens) it must not be updating the lat lng inputs because when the page reloads the original location instead of the new location in on the map
This is the code I'm using:
$('.submitButton').click(function () {
geocodeSearch();
});
$('.formInputTextPostcode').bind("enterKey",function(e){
$(".submitButton").click();
});
$('.formInputTextPostcode').keyup(function(e){
if(e.keyCode == 13)
{
$(this).trigger("enterKey");
}
});
function geocodeSearch(){
geocoder.geocode({
address: $('#postcodeViolet').val()+' UK'
}, function(results, status){
if(status == google.maps.GeocoderStatus.OK){
var geoPoint = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
map.setCenter(geoPoint);
circle.setCenter(geoPoint);
marker.setPosition(geoPoint);
$('#lattitude').val(geoPoint.lat());
$('#longitude').val(geoPoint.lng());
$("#searchForm").submit();
} else{
alert("Can not geolocate this address.");
}
});
}
So basically when I click the submit button, the location gets geocoded and the lat & lng inputs are updated then the form submits.
also the code is meant to wait for the enter key, and then cause it to click the submit button which should set in sequence the same code but for some reason when the page reloads the old location is on the map (if you click to submit the new location is there). Can anyone tell me what the difference is and why this is happening?
thanks