Return to Snippet

Revision: 62207
at February 7, 2013 19:25 by federicoq


Initial Code
var timeoutLocalita = 0;
	$("#localita").live('keyup', function() {
		clearTimeout(timeoutLocalita);
		timeoutLocalita = setTimeout('checkPosizione()', 500);
	});
	
	function checkPosizione() {
		console.log('vado con: ' + $("#localita").val() );
		$.post('/elementi/geotag', { where: $("#localita").val() }, function(res) {
			console.log(res);
			if(res.status == 'OK') {
				$("#localitaHelper").html(
					'Selezionato: ' + 
					res.results[0].address_components[2].long_name + 
					'<input type="hidden" name="lat" value="'+ res.results[0].geometry.location.lat + '" /><input type="hidden" name="lng" value="'+ res.results[0].geometry.location.lng +'" />');
			} else {
				$("#localitaHelper").html('Risultato: Località poco accurata.');
			}
		}, 'json');
		
	}

Initial URL

                                

Initial Description
trugg

Initial Title
Trigger del geotag

Initial Tags

                                

Initial Language
jQuery