私はCoffeescriptが初めてで、構文に苦労しています。CSで次のように書く方法を教えてくれる人はいますか?
$("#getLocation").click(function() {
$('#location-loading').show();
navigator.geolocation.getCurrentPosition(applyLocation);
return false;
});
function applyLocation(location) {
$('#LogLongitude').val(location.coords.longitude);
$('#LogLatitude').val(location.coords.latitude);
alert('Latitude:' + location.coords.latitude + ', Longitude: ' + location.coords.longitude + ', Accuracy: ' + location.coords.accuracy);
$('#location-loading').hide();
}
私は次のように動作すると思っていましたが、関数を呼び出して false を返すとエラーが発生します (そのため、リンクをたどりません)。
$('#getLocation').click ->
$('#location-loading').show()
navigator.geolocation.getCurrentPosition(applyLocation)
false
applyLocation = (location) ->
$('#LogLongitude').val(location.coords.longitude)
$('#LogLatitude').val(location.coords.latitude)
alert('Latitude:' + location.coords.latitude + ', Longitude: ' + location.coords.longitude + ', Accuracy: ' + location.coords.accuracy)
$('#location-loading').hide()