Here is the JS:
$('#createReview').click(function () {
CKEDITOR.instances['ReviewText'].updateElement();
$.ajax({
type: 'POST',
cache: false,
url: '/Review/Create',
data: $('#reviewForm').serialize(),
dataType: 'html',
success: function (response) {
$('#bookReview').html(response);
}
});
return false;
});
‘createReview’ is
The action:
[HttpPost, ExportModelState]
public ActionResult Create(Review review)
{
if (ModelState.IsValid)
{
if (review.Create())
return PartialView("EditReview", review);
}
return RedirectToAction("Edit");
}
When the form is posted, the review is created, but only the string property is binding–in this case the ReviewText. None of the integer properties are binding at all.
The strangest part is, when I run it in debug mode, none of the properties successfully bind, not even the ReviewText. When I inspect the Review object everything is either null or default.
I went back and forth between regular mode and debug, and it does the same thing every time.
I’m at a loss.
Edit:
Here is the full output of the Serialize() call, that won’t fit in a comment:
score=0&score=0&score=0&score=0&score=0&score=0&score=0&score=0&score=0&score=0&Book.Review.Rating=0&Rating=0&ReviewID=0&ParentBookID=1&reviewText=%3Cp%3E%0A%09I%26%2339%3Bm+an+idiot%3C%2Fp%3E%0A%3Cbr+%2F%3E%0A%3Cdiv+firebugversion%3D%221.5.4%22+id%3D%22_firebugConsole%22+style%3D%22display%3A+none%3B%22%3E%0A%09%26nbsp%3B%3C%2Fdiv%3E%0A%3Cbr+%2F%3E%0A&DateCreated=1%2F1%2F0001+12%3A00%3A00+AM
Note that “score” is nowhere to be found in my entire database, and all that junk about Firebug mixed in there.
Edit #2:
OK, so all those “score” inputs are coming from the jQuery Raty plugin, which was promptly un-plugin-ed.
Firebug is lousing up the text coming from the CKEditor instance, which is not even getting updated prior to form submission.
This client-side stuff sure is a blast!
Grrr…