Removing Ajax-based page loading from ASP.NET MVC 4 Beta applications
Posted: (EET/GMT+2)
I'm presently working on a mobile application that is written with ASP.NET MVC 4 Beta. By default, these applications use the jQuery Mobile libraries, in which Ajax-based page loading is on by default.
To disable this behavior, you will need to change a global flag within jQuery Mobile. This can be done in a .js script file that you load from within your ASP.NET MVC view page. However, order of script loading is important: to make sure the global flag set is effective, you need to do this immediately before jQuery Mobile itself has loaded, but after jQuery (and jQuery UI) has been loaded.
Here is the script code you need to execute:
$(document).bind("mobileinit", function () {
$.mobile.ajaxEnabled = false;
});
The easiest way to make sure this change affects all your view pages, you could edit the "_Layout.cshtml" page in the Views\Shared folder. This file is the default "master page" if you are using the Razor view engine.