views:

75

answers:

2

Can't seem to find a fix for this issue

I have the following code on the onclick event of an a html tag:

AddVacationToCart(  
{  
ServiceSupplier:'Kiki',  
ProductId:'0;11968;0;0;187;1',  
Name:'Excelsior',  
NumberOfStars:'*****',  
TotalPrice:'1620.00',  
PriceLevelName:'Standard',  
Currency:'EUR',  
Status:'',  
StartDate:'2010-06-17',  
EndDate:'2010-06-24',  
NumberOfNights:'7',  
Rooms:[  
{  
NumberOfAdults:'2',  
NumberOfChildren:'0',  
ChildrenAges:[]  
}  
]  
},'0;11968;0;0;187;1');return false;

I also have this code:

function AddVacationToCart(vacation, id) {
            $.post("/ShoppingCart.mvc/AddVacation",
        vacation,
        function(data) {
            var div = $("div[id*=cartv" + id + "]");
            var removeFromCartHtml = "Adaugat";
            $(div).html(removeFromCartHtml);
        }, "json");
        }

This is the code in my ShoppingCartController AddVacation Action:

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult AddVacation(Vacation test)
        {
...
}

The post works as in the (Vacation) test object gets filled with the corresponding properties like ServiceSupplier, ProductId, Name etc. Except the properties of my Rooms field do not get their corresponding values. Any ideeas?

A: 

I find that since 1.4 the ajax functions of JQuery are buggy as hell. I have scripts that work fine in every browser on every platform, with the exception of Chrome on Linux. I have filed bug reports to that effect and received no response so far.

joe_archer
A: 

Rooms is an array, so you have to name the props linke Rooms[0].NumberOfAdults, Rooms[1].NumberOfAdults to have the default modelbinder working as you expected.

Andrea Balducci