Skip to content Skip to sidebar Skip to footer

Jquery Ui Sortable() Method Not Supported Error

I'm developing an ASP.NET MVC 4 web application, which utilises the latest JQuery and JQuery UI libraries, and automatically has references to them (in the _Layout.cshtml page). I'

Solution 1:

In the _Layout.cshtml, it looks like at some point I manually referenced the JQuery and JQuery UI scripts, forgetting that the scripts were already rendered in bundles, e.g.

@Scripts.Render("~/bundles/jquery")

I was correctly referencing the right scripts but because they were being loaded again, I think they were destroying the first instances of the files, including the JQuery UI code, which relies on the JQuery file being loaded.

What I didn't understand also was that by default, ASP.NET MVC 4 applications do not render the JQuery UI framework, even though the files exist in the project and a script bundle is created in the BundleConfig.cs file.

Therefore, to fix my problems, I removed all the manual references so that only the bundles were being rendered, and added the following line to render the JQuery UI code in the head of my _Layout.cshtml file:

@Scripts.Render("~/bundles/jqueryui"); 

The way the bundles appear to work is that the Global.asax file invokes the 'RegisterBundles' method of the BundleConfig.cs, which creates new script bundles by searching for the relevant JavaScript files in the 'Scripts' folder and wherever else you tell it to look.

Then, to load the script files from the HTML, you have to render them using @Script.Render(), and providing the name of the script bundle as a parameter (e.g. "~/bundles/jqueryui").

To render all the scripts on every page of the website, you can add this to the _Layout.cshtml file, which is applied to every page.

Post a Comment for "Jquery Ui Sortable() Method Not Supported Error"