【发布时间】:2015-11-13 09:50:06
【问题描述】:
我从这里使用移动 jQuery 日历:http://demos.jquerymobile.com/1.4.1/datepicker/
看起来很简单,但我无法使用 onSelect 函数来捕捉所选日期。
我拥有的是这样的:
<link rel="stylesheet" href="http://code.jquery.com/mobile/git/jquery.mobile-git.css" />
<link rel="stylesheet" href="/jquery-mobile-datepicker-wrapper-master/jquery.mobile.datepicker.css" />
<link rel="stylesheet" href="/jquery-mobile-datepicker-wrapper-master/jquery.mobile.datepicker.theme.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="/jquery-mobile-datepicker-wrapper-master/external/jquery-ui/datepicker.js"></script>
<script src="http://code.jquery.com/mobile/git/jquery.mobile-git.js"></script>
<script src="/jquery-mobile-datepicker-wrapper-master/jquery.mobile.datepicker.js"></script>
<script>
$( document ).ready(function() {
$('.date-input-inline').datepicker({
onSelect: function(dateText, inst) {
alert("Date is : " + dateText);
}
});
});
</script>
然后是 HTML:
<body>
<input type="text" class="date-input-inline" data-inline="true" data-role="date">
正如您所期望的那样,这在我的网页上为我提供了一个输入字段和一个日历。
问题是,当我点击一个日期时,我得到no alert显示所选日期。
如何从这个日历中获取选定的日期,如果没有初始化,它是如何工作的?
脚本 src 中的文件正是取自 https://github.com/arschmitz/jquery-mobile-datepicker-wrapper 的文件
这里说 - https://github.com/arschmitz/jquery-mobile-datepicker-wrapper,它在 data-role="date" 上自动初始化。另外应该使用 date,而不是 datepicker。我试过了,但没有任何区别。
【问题讨论】: