Incompatible jquery mobile and ui

試著忘記壹切 提交于 2019-12-09 13:41:56

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/14578514/incompatible-jquery-mobile-and-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!