This project is read-only.

Postback Sorting

Jul 27, 2012 at 9:35 PM

Trying to get postback sorting working, and hoping someone might be able to point me in the right direction again. 


When I click any of my sortable headers I get the following Javascript error.

Error: TypeError: $("#" + elementField).parents("form").validate is not a function
Source File: http://localhost:53439/Scripts/MVCControlToolkit.Controls-2.2.0.js
Line: 206


Any thoughts?

Jul 27, 2012 at 10:08 PM

Before submitting the form the Mvc Controls Toolkit try to validated it, but the validate function is not defined. This means either no form is found, or the script of the jquery validation plugin where not inserted in the page.

Maybe also you have a form in the page but you have not inserted the enablesortingfor helper whithin the form.

Jul 28, 2012 at 2:10 AM

I'm defining my form:

  @using (Html.BeginForm("Index", "CurrentYear"))


and I see it in the generated HTML.  How would I tell if the correct validation plugin is being inserted?


I have the following in my _Layout.cshtml

 <script type='text/javascript' src="@Url.Content("~/Scripts/jquery-1.6.1.min.js")"></script>
    <script type='text/javascript' src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")"></script>
    <script type='text/javascript' src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
    <script type='text/javascript' src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
    <script type='text/javascript' src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>


I have the enable sorting declared right before the closing bracket for my form using statement

@Html.EnableSortingFor(m => m.Turtles, m => m.TurtleOrder, "NormalHeaderTurtle", "AscendingHeaderTurtle", "DescendingHeaderTurtle", true)

Jul 28, 2012 at 8:57 AM

put a submit button and see if validation works when clicking that button. If not there is a problem with the validation plugin. It looks like the validation script are defined adequately, but maybe there is a javascript error in the page that prevents the correct execution of the plugin.

You can see if there are js errors in the warnings tab of visual studio after you launch the program. Look for javascript syntax errors (they are reported as warnings)