jQuery UI对话框无法与JQuery Mobile一起使用 [英] Jquery UI dialog not working along side JQuery Mobile

查看:102
本文介绍了jQuery UI对话框无法与JQuery Mobile一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我同时包含JQuery mobile时,我无法在JQuery中使用一个简单的对话框:

I cannot get a simple dialog box working in JQuery when I also include JQuery mobile:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Dialog - Default functionality</title>


  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-2.1.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>


  <script>
  $( function() {
    $( "#dialog" ).dialog();
  } );
  </script>
</head>
<body  style="background-color: #888">

<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>


</body>
</html>

我已经看过以前的问题,这些问题似乎无济于事:

I have looked at these previous questions which do not seem to help:

  • jquery mobile dialog not working
  • Incompatible jquery mobile and ui

我在做什么错了?

推荐答案

阅读帖子

After reading the post Using multiple versions of jquery ui from RedNao i was able to create a simple proof of concept.

这个想法是交换两个jQuery实例,但是,请注意,我还没有针对大量使用代码进行全面测试.

The idea is to swap two instances of jQuery but, you are warned, i haven't fully tested against heavy usage in code.

之后,我将使用data-enhance="false"将UI对话框标记隐藏到jQuery Mobile中.

After that, i'm hiding the UI dialog markup to jQuery Mobile by using data-enhance="false".

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<link rel="stylesheet" href="style.css">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
   var jQM=jQuery, $QM=$;
</script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
  var jQUI=jQuery, $QUI=$;
  window.jQuery = jQM;
  window.$ = $QM;
  $(document).on('mobileinit', function () {
    $.mobile.ignoreContentEnabled = true;
  });

</script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

然后,它看起来像这样:

Then, it looks like this:

柱塞: https://plnkr.co/edit/oOg6cKEuMFXVrMn3ntCb?p=preview

这篇关于jQuery UI对话框无法与JQuery Mobile一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆