问题
I building a mobile views for my website and i am still in process of creating them. i want to test how it would look on live device. so i would like to disable the .mobile files and below i tired running some scripts to disable but no luck.
<script>$(function () {
$('html').find('*').attr('data-role', 'none');
});
</script>
<script>$(document).ready(function () {
// disable ajax nav
$.mobile.ajaxEnabled = false;
});
</script>
Maybe these is a question for the developers but if any one can point me in the right direction.
回答1:
You need to disable auto-initialization $.mobile.autoInitializePage of jQuery Mobile framework once mobileinit event is fired. Add the below code after jQuery (core) library and before jQuery Mobile in head.
<script src="jquery.js"></script>
<script>
$(document).on('mobileinit', function () {
$.mobile.autoInitializePage = false;
});
</script>
<script src="jquery-mobile.js"></srcipt>
To manually initialize jQuery Mobile, you need to call $.mobile.initializePage();
回答2:
hey Omar thanx for the help but i found it how disable it [blog.mirajavora.com/overriding-browser-capabilities-in-asp.net]
public class BrowserCapabilitiesSwitcherFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var switchParameter = f filterContext.RequestContext.HttpContext.Request.QueryString["switch"];
if(string.IsNullOrEmpty(switchParameter))
return;
var browserOverride = BrowserOverride.Desktop;
if(Enum.TryParse(switchParameter, true, out browserOverride))
{
//switch between BrowserOverride.Desktop / BrowserOverride.Mobile
filterContext.RequestContext.HttpContext.SetOverriddenBrowser(browserOverride);
}
else
{
//set the user-agent string
filterContext.RequestContext.HttpContext.SetOverriddenBrowser(switchParameter);
}
}
}
来源:https://stackoverflow.com/questions/25187671/how-to-disable-jquery-mobile-mvc