在日期范围内使用Mobiscroll [英] Using mobiscroll for a date range

查看:200
本文介绍了在日期范围内使用Mobiscroll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个网页,其中有2个滚动条来选择日期范围.两个文本输入都属于同一类,所以我将2个滚动条设置为:

I am trying to build a webpage where I have 2 scrollers to pick a range of dates. Both text inputs are the same class, so i am setting the 2 scrollers like so:

$('.datetime').scroller({

    preset: 'datetime', minDate: new Date(now.getFullYear(), now.getMonth(), (now.getDate() - 7)), theme: 'default', display: 'modal', timeFormat: 'HH:ii', timeWheels: 'HHii', stepMinute: 5, mode: 'scroller' 

}); 

我想做的就是让第二个滚动器将第一个滚动器设置的值设置为minDate.

What I'd like to do is to get the 2nd scroller to set as its minDate the value set by the first scroller.

我尝试使用eq()函数&将秒的minDate设置为$('.datetime').eq(0).val().我发现有2个问题:mobiscroll在文本输入中设置的值无法识别为日期; &该值似乎没有变化,但这可能是由于第一个错误引起的.

I tried setting up the scrollers separately, using the eq() function & setting the minDate of the second to $('.datetime').eq(0).val(). I found 2 problems with that: the value that is set by mobiscroll in the text input is not recognized as a date; & the value doesn't appear to change, but that may be due to the first error.

mobiscroll是否可以解析它加载到文本输入中的日期?我不想添加另一个插件,例如date.js只是为了使它能够按我的需要工作.

Does mobiscroll have a way of parsing the date that it loads into the text input? I'd rather not add another plugin like date.js just to get this one to work how I need it.

推荐答案

您可以使用mobiscroll的getDate方法:

You can use the getDate method of mobiscroll:

$('.datetime').eq(0).scroller('getDate');

这将返回日期对象,而不是字符串.

This returns a date object, not a string.

还有一个parseDate实用程序功能

There is also a parseDate utility function

$.scroller.parseDate(format, strValue);

有关更多信息,请参见 http://docs.mobiscroll.com/datetime-preset

For more information see http://docs.mobiscroll.com/datetime-preset

这篇关于在日期范围内使用Mobiscroll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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