How to include jQuery Mobile in Monodroid project?

Damir Dobric Posts

Next talks:



Follow me on Twitter: #ddobric




When working with jQuery Mobile applications you will have to include jQuery Mobile related assets in the javascript or HTML file.
Following HTML snippet shows how to do that:

<!DOCTYPE html>



       <title>DAENET’s Monodroid jQuery Mobile Demo</title>


       <meta name="viewport" content="width=device-width, initial-scale=1">


       <link rel="stylesheet" href="jQueryMobile/" />

       <script type="text/javascript" src="jQueryMobile/jquery-1.6.2.min.js"></script>

       <script type="text/javascript" src="jQueryMobile/"></script>



<a href="" data-role="button" data-theme="a" data-icon="star">Theme a</a>
<a href="" data-role="button" data-theme="b" data-icon="delete">Theme b</a>
<a href="" data-role="button" data-theme="c">Theme c</a>
<a href="" data-role="button" data-theme="d">Theme c</a>
<a href="" data-role="button" data-theme="e">Theme c</a>


To make this working, you will have to add all jQuery related staff to assets folder.


This is in fact all you have to do to make it running. Unfortunately this example will not work on Android, but it will work on Windows Phone, Windows 8 and common desktop based web application. When you start the code shown above, you will see following result:


This means that jQuery has not been loaded correctly.The reason for that is that Android asset loading routines are case-sensitive. If you carefully take a look on the
name of jquery-mobile asset folder you will find this name: “jquerymobile” (see picture above).

All include files use name jQueryMobile:

<link rel="stylesheet" href="jQueryMobile/" />

To make it working change all of them as shown below:

<link rel="stylesheet" href="jquerymobile/" />

<script type="text/javascript" src="jquerymobile/jquery-1.6.2.min.js"></script>

<script type="text/javascript" src="jquerymobile/"></script>

Start application again and this is the result:


Recap: If you are implementing the HTML5 application which should support all platforms, you should build everything case-sensitive.

Posted Sep 18 2011, 02:23 PM by Damir Dobric is a .Net Community Blog powered by daenet GmbH.