Using mobiscroll for a date range

六月ゝ 毕业季﹏ 提交于 2019-12-25 05:29:08

问题


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' 

}); 

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

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.

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.


回答1:


You can use the getDate method of mobiscroll:

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

This returns a date object, not a string.

There is also a parseDate utility function

$.scroller.parseDate(format, strValue);

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



来源:https://stackoverflow.com/questions/11852970/using-mobiscroll-for-a-date-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!