Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use jQuery Mobile for its touch event support only (no UI enhancements)?

I’m working on a web app that has its own look and feel. I want to use jQuery Mobile for the touch events support only.

When I link jquery.mobile.min.js (without linking the css), then the layout of my page is broken.

How can I configure (initialize) jQuery Mobile to only use touch events support? Would I bind the events in the jQuery document ready hook since I'd not have any JQM page related event?

Edit

See this example in jsfiddle: http://jsfiddle.net/redhotsly/JGgrw/. The html contains a <button> but jQuery Mobile created a <span> to its left. If you inspect the resulting markup (F12) you will see that jQuery Mobile also added a CSS class to my button.

Edit:

I need a solution where I'll not have modify the JQM script. I need to use the official script off a CDN.

like image 657
Sylvain Avatar asked Dec 27 '11 19:12

Sylvain


People also ask

What is jQuery Mobile and how is it used?

The framework allows developers to build applications that can be accessed by the widest number of browsers and devices, whether it is Internet Explorer 6 or the newest Android or iPhone. Mobile jQuery also gives developers the ability to render basic content (as built) on basic devices.

Is jQuery Mobile supported?

jQuery Mobile Supported PlatformsjQuery Mobile has broad support for the vast majority of all modern desktop, smartphone, tablet, and e-reader platforms. In addition, feature phones and older browsers are supported because of our progressive enhancement approach.

Is jQuery Mobile open source?

Features of jQuery MobileOpen-source and freely available for all kind of usages. Cross-platform, cross-device and cross-browser compatible.


1 Answers

If you want to use jQuery mobile for touch events only, add this piece of script before you load the jQuery mobile library:

<script type="text/javascript">$(document).bind("mobileinit", function(){$.extend(  $.mobile , {autoInitializePage: false})});</script> 

This prevents jquery mobile from initializing the page and touching the DOM, thus leaving your layout alone.

like image 64
eivers88 Avatar answered Sep 23 '22 13:09

eivers88