Reputation: 29113
I'm using jquery-mobile for a Google Apps Script that I want to load as a web app but also as a dialog/sidebar in Sheets. In the script I use jquery-mobile's grid support, so I require its css & js. However, I don't want it's theming when on the desktop. Is there a way to turn it off if the device is not mobile?
Upvotes: 0
Views: 102
Reputation: 31732
You can control jQuery Mobile's framework auto initializing. On mobileinit
event - which fires before .ready()
- check if user agent is a desktop or tablet/mobile. If it's a desktop browser, stop jQuery Mobile from auto initializing the framework.
The code below should be placed in head
after jQuery.js (core) and before jQuery-Mobile.js
$(document).on("mobileinit", function (e, data) {
if ( isDesktop() ) { /* isDesktop() is your custom function to check user agent */
$.mobile.autoInitializePage = false;
}
});
Now, your website isn't controlled by jQuery Mobile, however, you still can use grid system as it is only classes and there is no JavaScript code involved.
Upvotes: 1