3

I have successfully created a new Cordova Windows Phone 8 Project using CLI.

I have also successfully added this Date time picker Plguin also, [Like it says on that page using CLI]

That plugin is for displaying native Date Time Picker on Textbox.

Now iam trying to invoke that plugin,

I tried,

<input type="Date" id="samp" />
<input type="datetime" id="samp" />
<input type="datetime-local" id="samp" />

etc.. in my code, but no native datetime picker is displaying in my app. Can somebody help me on this ??

Can somebody tell me how to invoke this Datetime Picker Plugin. ?

Jaihind
  • 2,762
  • 1
  • 10
  • 19
locknies
  • 1,240
  • 2
  • 15
  • 32
  • https://github.com/leecrossley/phonegap-wp8-datepicker-plugin try this plugin – Jaihind Apr 23 '14 at 10:59
  • Both the plugins are same. the link above provided allows to install the same plugin via git installer. If you look at the link you will understand better. Am i invoking that plugin correctly? i mean, is it correct that how i used that plugin ? – locknies Apr 23 '14 at 11:01

2 Answers2

3

I asked this question to the creator itself and he explained me how to do it.

There’s no detailed documentation (yet). Something like this would show the date picker when an element with class “date-input” is clicked (untested):

Eg: <input type="text" class="date-input" />

[you have to do something to avoid the soft keyboard, what about making it 'readonly'?]

$(".date-input").bind("click", function() {
    datetimepicker.selectDate(function (date) {
        console.log(date);
    });
});

Once the date is selected, the callback function will log the selected date to the console, but you can do whatever with it.

The callback function will return a value. You have to parse it to get it in date format. This code would convert to a JavaScript date object:

date = new Date(parseInt(date, 10));

You can then format the date in any way you want.


Eg: <input type="text" class="time-input" />

[you have to do something to avoid the soft keyboard, what about making it 'readonly'?]

$(".time-input").bind("click", function() {
    datetimepicker.selectTime(function (time) {
        console.log(time);
    });
});

Like that you can also use time too.

:-) Happy coding..!!

locknies
  • 1,240
  • 2
  • 15
  • 32
  • It took me a while to figure out how to add the nuget packages that this datepicker depends on. I had to open up the project (csproj) under bld/debug/platforms/wp8 and manage the nuget packages from there. Maybe this is documented somewhere or there is a better way, but I could not find it. – Scott Aug 01 '15 at 21:52
0

You can simply avoid using an "Input" tag to invoke datetimepicker picker. Why ?? Input tag will first invoke default keyboard on focus. Instead use a span or div tag.