在Windows Phone 8中调用日期时间选择器插件 [英] Invoking Date Time Picker plugin in Windows Phone 8

查看:65
本文介绍了在Windows Phone 8中调用日期时间选择器插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用CLI成功创建了一个新的Cordova Windows Phone 8项目.

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

我还成功添加了日期时间选择器Plguin , [就像使用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,

我尝试过

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

我的代码中是

etc ..,但是我的应用程序中没有显示本机日期时间选择器.有人可以帮我吗?

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

有人可以告诉我如何调用此Datetime Picker插件. ?

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

推荐答案

我向创作者问了这个问题,他向我解释了如何做.

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

尚无详细文档(尚未).单击(未经测试)具有"date-input"类的元素时,类似这样的内容将显示日期选择器:

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

例如:<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.

回调函数将返回一个值.您必须对其进行解析才能以日期格式获取它. 这段代码将转换为JavaScript日期对象:

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.

例如:<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..!!

这篇关于在Windows Phone 8中调用日期时间选择器插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆