Reputation: 21
i am facing a problem in the nerddinner, what i am facing:
in the DinnerForm.ascx there is a javascript code
$(document).ready(function () {
NerdDinner.EnableMapMouseClickCallback();
$("#Dinner_Address").blur(function (evt) {
//If it's time to look for an address,
// clear out the Lat and Lon
$("#Dinner_Latitude").val("0");
$("#Dinner_Longitude").val("0");
var address = jQuery.trim($("#Dinner_Address").val());
if (address.length < 1)
return;
NerdDinner.FindAddressOnMap(address);
});
});
when i run the project, and i insert new Dinner, the longitude and the latitude inserted with value 0;
and when i changed the "0" to any number
$(document).ready(function () { NerdDinner.EnableMapMouseClickCallback();
$("#Dinner_Address").blur(function (evt) {
//If it's time to look for an address,
// clear out the Lat and Lon
$("#Dinner_Latitude").val("12");//
$("#Dinner_Longitude").val("12");//
var address = jQuery.trim($("#Dinner_Address").val());
if (address.length < 1)
return;
NerdDinner.FindAddressOnMap(address);
});
});
it inserts the value 12 for both long and lat to the database
so i knew its inserting this value to the database, but am not sure actually
so i really want to know how i can fix this, plz any one :D
Upvotes: 2
Views: 1314
Reputation: 4440
My problem was that none of the values in the edit page were persisted. It was an issue in DinnersController.cs.
I changed
UpdateModel(dinner, "Dinner");
to
UpdateModel(dinner);
It seemed that the problem was that the controller code was expecting keys named Dinner.Id, Dinner.Title, etc. but the keys were actually named just Id and Title (etc.).
Upvotes: 0
Reputation: 4420
Look in Scripts/NerdDinner.js for this block of code:
//If we've found exactly one place, that's our address.
//lat/long precision was getting lost here with toLocaleString, changed to toString
if (NerdDinner._points.length === 1) {
$("#Latitude").val(NerdDinner._points[0].Latitude.toString());
$("#Longitude").val(NerdDinner._points[0].Longitude.toString());
}
The problem appears to be that this script tries to set the values for elements named Latitude and Longitude, but in Views\Dinners\DinnerForm.ascx, those element ids are resolved as Dinner_Latitude and Dinner_Longitude, respectively. As a workaround, you should be able modify two lines in NerdDinner.js so it would update either element it finds:
if (NerdDinner._points.length === 1) {
$("#Latitude,#Dinner_Latitude").val(NerdDinner._points[0].Latitude.toString());
$("#Longitude,#Dinner_Longitude").val(NerdDinner._points[0].Longitude.toString());
}
Upvotes: 1