IttayD
IttayD

Reputation: 29113

jquery-mobile: turn off theming for desktop

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

Answers (2)

Omar
Omar

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

dr_dev
dr_dev

Reputation: 522

Wrap up everything inside a form and set the property data-role to none, for the form. Refer to the documentation here

It's a bit old though. But, I guess same should work.

Upvotes: 0

Related Questions