我正在尝试在phonegap中创建我的第一个移动应用。我正在尝试使用适用于Android的datepicker插件。我的HTML在下面。我只看到两个改变“Phonegap正在工作”和警报#1。它没有在焦点事件中显示任何警报,当然,它似乎没有工作。我错过了什么吗?
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script>
document.addEventListener("deviceready",onDeviceReady, false);
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working!!");
}
alert('1 '+new Date());
$('.nativedatepicker').focus(function(event) {
var currentField = $(this);
alert('2 '+new Date());
alert('3 '+currentField.val());
var myNewDate = Date.parse(currentField.val()) || new Date();
alert('4 '+new Date());
// Same handling for iPhone and Android
window.plugins.datePicker.show({
date : myNewDate,
mode : 'date', // date or time or blank for both
allowOldDates : true
}, function(returnDate) {
var newDate = new Date(returnDate);
currentField.val(newDate.toString("dd/MMM/yyyy"));
// This fixes the problem you mention at the bottom of this script with it not working a second/third time around, because it is in focus.
currentField.blur();
});
});
</script>
</head>
<body>
<input id="meeting" type="text" value="09/Feb/2013" class="nativedatepicker"/>
</body>
</html>
答案 0 :(得分:1)
使用此链接,这可能会帮助您进行插件 https://github.com/phonegap/phonegap-plugins/tree/master/Android/DatePicker
并且还有这个链接 http://code.google.com/p/mobiscroll/