【问题标题】:Phonegap Android datepickerPhonegap Android 日期选择器
【发布时间】:2013-02-24 13:46:32
【问题描述】:

我正在使用 Phonegap 构建一个 Android 应用程序,我发现 this plugin 我决定将其用于我的日期选择器字段。我按照说明进行操作,但运行时遇到问题。

这是我的代码:

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();
  });
}; 

在创建com.phonegap.plugin 包后,我已将datePickerPlugin.js 添加到/assets/www/js/,并将DatePickerPlugin.java 添加到/src/com/phonegap/plugin/

我想我在调用 datePickerPlugin.js 时可能会遇到一些问题,因为我没有收到我在文件中放入的警报,但我不确定如何解决。

提前致谢。

【问题讨论】:

  • 您的 index.html 文件中是否包含 datepickerplugin.js 文件且路径正确?

标签: java android cordova backbone.js datepicker


【解决方案1】:

我遇到了类似的问题。我通过在 cordova.js 之后包含 datePickerPlugin.js 文件来解决它。

【讨论】:

    【解决方案2】:

    感谢两位提示我查看我的路径。看来我没有正确包含我的 Cordova 库文件。在我这样做之后,一切都像魅力一样发挥作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多