Phonegap を使用して Android アプリケーションを構築していますが、このプラグインを見つけて、datepicker フィールドに使用することにしました。指示に従いますが、実行に問題があります。
これが私のコードです:
HTML:
<label for="schedule_start">Start date</label>
<input type="text" class="nativedatepicker" id="schedule_start" name="schedule[start_date]" value="{{start_date}}" required />
JS (私は Backbone.js を使用しています)
FormView.prototype.defaultEvents = {
'focus .nativedatepicker': 'focusDatepicker'
};
// call when input focused
FormView.prototype.focusDatepicker = function(e) {
var currentField = $(this);
var myNewDate = Date.parse(currentField.val()) || new Date();
if(typeof myNewDate === "number"){ myNewDate = new Date (myNewDate); }
// 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("YYYY-MM-DD"));
// 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();
});
};
パッケージを作成した後、 datePickerPlugin.js
to/assets/www/js/
とDatePickerPlugin.java
toを追加しました。/src/com/phonegap/plugin/
com.phonegap.plugin
ファイルに入力したアラートが表示されないため、datePickerPlugin.js の呼び出しに問題がある可能性があると思いますが、それを解決する方法がわかりません。
前もって感謝します。