Note that there are some explanatory texts on larger screens.

plurals
  1. POPhonegap Android datepicker
    primarykey
    data
    text
    <p>I am building an Android application using Phonegap and I found <a href="https://github.com/phonegap/phonegap-plugins/tree/master/Android/DatePicker" rel="nofollow">this plugin</a> which I decided to use for my datepicker fields. I follow the instructions, but I have trouble running that.</p> <p>Here is my code:</p> <p>HTML:</p> <pre><code>&lt;label for="schedule_start"&gt;Start date&lt;/label&gt; &lt;input type="text" class="nativedatepicker" id="schedule_start" name="schedule[start_date]" value="{{start_date}}" required /&gt; </code></pre> <p>JS (I'm using Backbone.js)</p> <pre><code>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(); }); }; </code></pre> <p>I've added the <code>datePickerPlugin.js</code> to <code>/assets/www/js/</code> and the <code>DatePickerPlugin.java</code> to <code>/src/com/phonegap/plugin/</code> after creating the <code>com.phonegap.plugin</code> package.</p> <p>I think I might have some problem invoking the datePickerPlugin.js, since I don't get the alert I put in the file, but I'm not sure how to resolve that.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload