Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible jquery mobile and ui

Although I have a ton of people referencing to similar compatibility issues, 50% their problems are solved on StackOverflow. I am hoping my question will make it 51-49 :)

Consider this code:

<html>
<head>
  <title>Hello, world!</title>
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
</head>
<body>
  Hello
</body>
</html>

If you load this on a web page, you will get a grey circle in the middle of the browser and the word "Hello" is not displayed. On the web console, you'll see the following: Uncaught TypeError: Object 0 has no method 'match' (Chrome) or TypeError: c.match is not a function (Firefox) or SCRIPT438: Object doesn't support property or method 'match' (IE).

Is it a bad idea to want to use both jquery-ui and jquery-mobile on a page together, or am I doing something wrong?

like image 906
Sudipta Chatterjee Avatar asked Jan 14 '23 09:01

Sudipta Chatterjee


1 Answers

Only thing relevant is an order, load jQM after jUI, same thing goes for css files:

<!DOCTYPE html>
<html>
<head>
  <title>jQM Complex Demo</title>
  <meta name="viewport" content="width=device-width"/>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />    
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
  <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>    
  <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
    <div data-role="page" id="index">    
      Hello
    </div>
</body>
</html>

Also you need:

<!DOCTYPE html>

And this will prevent ajax loader prom showing:

<div data-role="page" id="index">    
    Hello
</div>
like image 194
Gajotres Avatar answered Jan 31 '23 07:01

Gajotres