I'm using MVC 3 with UnobtrusiveJS enabled.
I have a form created with Ajax.BeginForm with a DropDown in there. I have an onchange=this.form.onsubmit handler to submit the form when the value changes.
The problem is that my browser console is showing the message "Uncaught TypeError: Property 'onsubmit' of object # is not a function" when i change the dropdown.
If i change the handler to this.form.submit() it submits the form fine but without ajax.
I've referenced jquery, jquery-unobtrusive-ajax and the MS Ajax js files, but with no luck.
If i disable UnobtrusiveJS, it works fine.
Any ideas?
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script>
View:
@using (Ajax.BeginForm("AddToGroup", new AjaxOptions() { UpdateTargetId = "statusText" }))
{
@Html.Hidden("username", @friendProfile.Username)
@Html.DropDownList("groupId", @Model.UserGroups, "Add to group...", new { @onchange = "this.form.onsubmit()" })
<input type="submit" value="Submit" />
<span id="statusText"></span>
}