如果jQueryUI小部件(datepicker)在页面上调用,jQueryMobile页面将不会加载?
我主要在构建这个网站时使用jQuery Mobile,但我已经为Mobile中缺少的一些功能包括了jQuery UI,比如网站中主要从桌面访问的部分的日期选择器。当直接加载页面时,一切正常,但我实际上无法从站点的其他位置导航到页面——AJAX加载微调器只是旋转。我在控制台中看到一个错误:TypeError:$..datepicker不是一个函数。我假设这与jquerymobile的AJAX页面加载有关,并且修复程序与API信息中的pageinit信息有关,但我缺乏应用这一点的理解 换句话说,我如何转换$mydatepicker.datepicker;在pageinit上工作的东西 编辑:按要求编辑页眉:如果jQueryUI小部件(datepicker)在页面上调用,jQueryMobile页面将不会加载?,jquery,jquery-ui,jquery-mobile,jquery-ui-datepicker,Jquery,Jquery Ui,Jquery Mobile,Jquery Ui Datepicker,我主要在构建这个网站时使用jQuery Mobile,但我已经为Mobile中缺少的一些功能包括了jQuery UI,比如网站中主要从桌面访问的部分的日期选择器。当直接加载页面时,一切正常,但我实际上无法从站点的其他位置导航到页面——AJAX加载微调器只是旋转。我在控制台中看到一个错误:TypeError:$..datepicker不是一个函数。我假设这与jquerymobile的AJAX页面加载有关,并且修复程序与API信息中的pageinit信息有关,但我缺乏应用这一点的理解 换句话说,我如
<head>
<meta charset="utf-8">
<title>Test Site</title>
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="cleartype" content="on">
<link rel="stylesheet" href="_css/normalize.css" />
<link rel="stylesheet" href="_css/red_ui_variant/jquery-ui-1.10.3.custom.min.css" />
<link rel="stylesheet" href="_css/jquery.mobile.structure-1.3.1.css" />
<link rel="stylesheet" href="_css/red_mobile_variant.css" />
<link rel="stylesheet" href="_libraries/foundation-4.1.5.custom/css/foundation.css" />
<link rel="stylesheet" href="_css/main.css" />
<script src="_scripts/vendor/custom.modernizr.js"></script>
<script src="ckeditor/ckeditor.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="_scripts/jquery-migrate-1.1.1.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
</head>
在jQueryMobile中使用jQueryUI时,在jQueryMobile之前对其进行初始化是很重要的,在任何其他情况下它都不起作用。基本上你的头应该是这样的:
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/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.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
$(document).on('pageinit', '#index', function(){
$( "#datepicker" ).datepicker();
});
下面是一个有效的例子:
最后一件事,如果您想了解更多关于jQuery Mobile页面事件的信息,请查看我的另一个答案:当将jQuery UI与jQuery Mobile一起使用时,在jQuery Mobile之前对其进行初始化非常重要,在任何其他情况下都不起作用。基本上你的头应该是这样的:
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/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.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
$(document).on('pageinit', '#index', function(){
$( "#datepicker" ).datepicker();
});
下面是一个有效的例子:
最后一件事,如果您想了解更多关于jQuery移动页面事件的信息,请查看我的另一个答案:在您的问题中添加HTML标题?我想我知道可能是什么问题,但首先我需要查看您的HTML。@Gajotres更新。这可能只是链接的顺序吗?在你的问题中添加HTML标题?我想我知道可能是什么问题,但首先我需要查看您的HTML。@Gajotres更新。这可能只是链接的顺序吗?