Context: I'm doing sorting using Sortable
.
$("#sortable").sortable({
update: function (e,ui)
{
nextItemPrio=parseFloat(ui.item.next().find("input[name='Priority']").val().replace(",", "."));
prevItemPrio = parseFloat(ui.item.prev().find("input[name='Priority']").val().replace(",", "."));
currentItemPrio = parseFloat(ui.item.find("input[name='Priority']").val().replace(",", "."));
if ((nextItemPrio < currentItemPrio && prevItemPrio < currentItemPrio)
|| (nextItemPrio > currentItemPrio && prevItemPrio > currentItemPrio)) {
ui.item.find("input[name='Priority']").val((prevItemPrio + nextItemPrio) / 2.0);
}
In controller I have:
public ActionResult UpdatePicturePriority(int id, string newpriority)
{
var a = _PictureRepo.GetById(id);
decimal convertDecimal = Convert.ToDecimal(newpriority.Replace(".", ","),);
a.Priority = convertDecimal;
_PictureRepo.Update(a);
return Json(true);
}
After few sortings (divings),I get some number like 0,0023565
but it seems that is convert to 0
when I post the value to controller (MVC application). I don't want this, because my code doesn't work after few dividings. I don't want that my numbers get rounded.