jQuery Datepicker:单击日期时防止关闭选择器 [英] jQuery Datepicker: Prevent closing picker when clicking a date

查看:35
本文介绍了jQuery Datepicker:单击日期时防止关闭选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,stackoverflow:ers,

Hi fellow stackoverflow:ers,

我正在使用 jQuery Datepicker 插件,以及 <一个 href="http://milesich.com/timepicker/" rel="noreferrer">Martin Milesich Timepicker 插件.一切都很好,除了在日期选择器中单击日期会关闭小部件,没有时间选择时间.

I'm using the jQuery Datepicker plugin, together with Martin Milesich Timepicker plugin. Everything works great, except for the fact that clicking a date in the datepicker, closes the widget, leaving no time to pick the time.

问题:所以我想知道是否有办法防止小部件在单击日期时关闭,而是强制用户单击完成"按钮(启用showButtonPanel:true"选项时显示),或单击小部件外部.我不希望我的用户不得不两次打开小部件!在 timepicker 演示中在线查看行为

Question: So I'm wondering if there's a way to prevent the widget from closing when clicking a date, and instead force users to click the "Done" button (that shows up when enabling the "showButtonPanel: true" option), or clicking outside of the widget. I don't want my users having to open the widget twice! See the behavior online at the timepicker demo

感谢您对解决此问题的任何帮助,甚至是正确方向的指示!

Any help solving this issue, or even pointers in the right direction, is appreciated!

更多信息:我正在使用 Martins 下载链接提供的文件:http://milesich.com/tpdemo/timepicker-0.2.0.zip

More info: I'm using the files supplied from Martins download link: http://milesich.com/tpdemo/timepicker-0.2.0.zip

  • jquery-ui-1.7.2.custom.min.js
  • timepicker.js(最新版本 0.2.0)

这些是我正在使用的选项:

These are the options I'm using:

$(document).ready(function(){
    $(".datepicker").datepicker({
        duration: '',  
        showTime: true,  
        constrainInput: false,  
        stepMinutes: 5,  
        stepHours: 1, 
        time24h: true,
        dateFormat: "yy-mm-dd",
        buttonImage: '/static/images/datepicker.png',
        buttonImageOnly: true,
        firstDay: 1,
        monthNames: ['Januari','Februari','Mars','April','Maj','Juni','Juli','Augusti','September','Oktober','November','December'],
        showOn: 'both',
        showButtonPanel: true
     });
})

推荐答案

与其改变源,不如使用现有事件

rather than changing the source it's best to use the existing events

onSelect: function() {
    $(this).data('datepicker').inline = true;                               
},
onClose: function() {
    $(this).data('datepicker').inline = false;
}

这篇关于jQuery Datepicker:单击日期时防止关闭选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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