Or maybe its the other way around?
I am new MVC so be gentle. I can select a value from a Html.DropDownList
and it populates to the model when saved. However if I click out of the box jQuery.Validate
barks at me with an error about null data.
This is the error
+ this function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} Object, (Function)
This is the view
@model Game.Domain.Equipment
<div class="editor-label">
@Html.LabelFor(model => model.BaseGameObject.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.BaseGameObject.Name) @Html.ValidationMessageFor(model => model.BaseGameObject.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.BaseGameObject.Description)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.BaseGameObject.Description) @Html.ValidationMessageFor(model => model.BaseGameObject.Description)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Type)
</div>
<div class="editor-field">
@Html.DropDownListFor(model => model.Type, new SelectList(Enum.GetValues(typeof(Game.Domain.EquipmentType))))
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Value)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Value) @Html.ValidationMessageFor(model => model.Value)
</div>
This is the model
namespace Game.Domain
{
public class Equipment
{
public Equipment()
{
BaseGameObject = new BaseGameObject();
}
public virtual int Id { get; set; }
public virtual BaseGameObject BaseGameObject { get; set; }
public virtual EquipmentType Type { get; set; }
public virtual int Value { get; set; }
}
}
I have attempted to turn off the jvalidate jquery with jquery
$(function () {
var select = $('select');
$('select').attr("willValidate", false)
});
But no matter what I try I get same jvalidate error over and over. Its damned annoying =)