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

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

问题描述

你好stackoverflow:ers,

Hi fellow stackoverflow:ers,

我正在使用 jQuery Datepicker插件,以及 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


  • 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天全站免登陆