jQuery Mobile for mobile and desktop?

ZolaKt picture ZolaKt · Feb 19, 2011 · Viewed 25.6k times · Source

I'm developing a web app. MySql/PHP back-end, and HTML/jQuery front-end.

I wanted to use jQuery UI framework.

Now is see that jQuery Mobile is out, and I want to make the app accessible to mobile devices as much as possible.

I Googled, but didn't find a quality answer.

Can I make it all to work form the same code if I use jQuery Mobile?

I'd like it to show mobile widgets if accessed form mobile browser.
But use jQuery UI widgets is accessed from desktop browser.

Is that possible just by using jQuery Mobile and its markup, or I have to write the front-end for mobile (jQuery Mobile) and desktop (jQuery UI) separately?

That is, can jQuery Mobile, automatically "fall-back" to jQuery UI if accessed from desktop browser.

Answer

TNC picture TNC · Feb 19, 2011

I think it largely depends on what you want to do and functionality you're trying to capture. If you want a webpage to behave a certain way on mobile and the same desktop, then with some careful coding/testing, you'll be alright with jquery.mobile.

If you check out the CSS for jquery.mobile (uncompressed version), you can actually edit the code directly to show the HTML elements the way you want to for particular screen sizes. Just select the one for desktop / large screen sizes to scale appropriately.

Depending on what you're trying to accomplish in terms of your mobile version, I'd also check out jQTouch - which allows for mobile-specific functionality, such as "tap" (in place of "click"), as an example - but also has a desktopCompatability option, so it reverts for desktop browsers.

One note, with either of these libraries, you'll still need the root jquery library.

Hope this helps.