jQuery Mobile 日期选择器配置
我正在开发 Web 应用程序的移动版本,但在 jQ mobile 中配置日期选择器时遇到一些问题。我知道这是一个实验性功能(我想它可能有点问题?),但我认为配置它应该不是问题。
但是,我似乎无法让它发挥作用。我查看了 jQ UI 文档,为我的日期选择器提供了以下配置:
$(document).ready(function(){
$("#mo_date").datepicker({
showAnim: 'fadeIn',
dateFormat: 'dd-mm-yy',
dayNamesShort: ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
dayNamesMin: ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
monthNames: ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
monthNamesShort: ['Jan','Feb','Maa','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],
minDate: 0,
// altField outputs date in mySQL date format yy-m-d. datum hieruit halen, ipv .datepicker('getDate');
// altField: '.output_date',
// altFormat: 'yy-m-d'
});
});
我的 HTML 如下:
<form action="mobile/go" method="post">
<div data-role="fieldcontain">
<label for="mo_event_type" class="select">Kies type taak</label>
<select name="mo_event_type" id="mo_event_type" data-native-menu="false">
<option data-placeholder="true">Taaktype</option>
<option value="huiswerk">Huiswerk</option>
<option value="deadline">Deadline</option>
<option value="vrijetijd">Vrije tijd</option>
</select>
</div>
<div data-role="fieldcontain">
<label for="mo_title">Titel</label>
<input type="text" name="mo_title" value="" id="mo_title" data-theme="b"/>
</div>
<div data-role="fieldcontain">
<label for="mo_descr">Beschrijving</label>
<textarea cols="20" rows="8" name="mo_descr" id="mo_descr" data-theme="b"></textarea>
</div>
<div date-role="fieldcontain">
<label for="mo_date">Datum</label>
<input type="date" name="mo_date" id="mo_date" value="" />
</div>
</form>
我是否在这里遗漏了一些重要的内容,或者我只是做错了?一些见解将不胜感激。我知道配置很好,因为我在非移动应用程序中使用了相同的配置。只是无法让它与移动设备一起使用:(
非常感谢。
I'm working on a mobile version of my web application, but I have some trouble with configuring a datepicker in jQ mobile. I know it's an experimental feature (I suppose it might be a bit buggy?), but I figured configuring it shouldn't really be a problem.
However, I can't seem to get it working. I looked at the jQ UI documentation to come up with the following configuration for my datepicker:
$(document).ready(function(){
$("#mo_date").datepicker({
showAnim: 'fadeIn',
dateFormat: 'dd-mm-yy',
dayNamesShort: ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
dayNamesMin: ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
monthNames: ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
monthNamesShort: ['Jan','Feb','Maa','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],
minDate: 0,
// altField outputs date in mySQL date format yy-m-d. datum hieruit halen, ipv .datepicker('getDate');
// altField: '.output_date',
// altFormat: 'yy-m-d'
});
});
My HTML is as follows:
<form action="mobile/go" method="post">
<div data-role="fieldcontain">
<label for="mo_event_type" class="select">Kies type taak</label>
<select name="mo_event_type" id="mo_event_type" data-native-menu="false">
<option data-placeholder="true">Taaktype</option>
<option value="huiswerk">Huiswerk</option>
<option value="deadline">Deadline</option>
<option value="vrijetijd">Vrije tijd</option>
</select>
</div>
<div data-role="fieldcontain">
<label for="mo_title">Titel</label>
<input type="text" name="mo_title" value="" id="mo_title" data-theme="b"/>
</div>
<div data-role="fieldcontain">
<label for="mo_descr">Beschrijving</label>
<textarea cols="20" rows="8" name="mo_descr" id="mo_descr" data-theme="b"></textarea>
</div>
<div date-role="fieldcontain">
<label for="mo_date">Datum</label>
<input type="date" name="mo_date" id="mo_date" value="" />
</div>
</form>
Am I missing something crucial here or am I just doing it plain wrong? Some insight would be appreciated. I know the configuration is fine since I'm using the same for my non-mobile application. Just can't get it to work with the mobile one :(
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我更喜欢 DateBox 插件: http://dev.jtsage.com/jQM-DateBox /
在实验 DP 的文档中:http://jquerymobile.com/demos/1.0a4.1/experiments/ui-datepicker/
请务必将此事件绑定放在在 jQuery 之后、jQuery Mobile 之前加载的脚本中。检查此页面的源代码以获取示例。
我还注意到,许多人无法获得与 DP 一起使用的附加选项,
我为 DateBox:
单行版本提供了这个:
First I like the DateBox plugin a little better IMO: http://dev.jtsage.com/jQM-DateBox/
In the Documentation for the Experimental DP: http://jquerymobile.com/demos/1.0a4.1/experiments/ui-datepicker/
Be sure to place this event binding in a script that loads after jQuery, but before jQuery Mobile. Check this page's source for an example.
I have also noticed that many can not get additional options to work with the DP
I had this for the DateBox:
single line version: