防止打开日历的timepicker插件 [英] Prevent timepicker addon from opening calendar

查看:62
本文介绍了防止打开日历的timepicker插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在旧问题中询问了以下内容:

I asked the following in an old question:


我正在使用jquery的timepicker插件。一旦用户选择日期+时间并点击完成按钮,基本上只关闭对话框,我想要设置日期时间的文本框获得后焦点(插件的当前行为是模糊焦点)。这是因为在这个页面上我有一组文本框,它们的Tab键顺序是按顺序设置的。我需要日期时间文本框来获得后焦点以继续Tab键顺序。否则标签顺序将从第一个文本输入重新开始,这对用户来说是不方便的。

I'm using the timepicker plugin for jquery. once users selected a date+time and click on the "Done" button, which basically just closes the dialog, i want the textbox where datetime is set to gain back focus (the current behavior of the plugin is to blur out focus). This is because on this page i have a set of textboxes and their tab orders are set sequentially. i need the datetime textbox to gain back focus to continue the tab order. otherwise the tab order will restart from the first text input which is inconvenient for the user.

我回到了下面的工作答案

I got back a working answer below

$('#MyDatepicker').datetimepicker({
   onClose: function(dateText, inst) {
     $('#MyDatepicker').focus();
  }
});

但这是我的新挑战:现在文本框重点关注,日历再次打开。我如何防止这种情况?

but this is my new challenge: now the textbox has its focus back, the calendar opens again. how do i prevent that?

推荐答案

所以我在周末试图把它弄到这里后想到了这个工作,当我意识到最好的行为可能不是重点关注!考虑到您的用户,一旦他们明确选择了某个日期,他们为什么要将重点放在同一个领域?因此,将焦点设置为下一个输入。

So I was thinking about this one over the weekend after messing around with trying to get it to work, when I realized that maybe the best behavior is not to set focus back at all! Thinking about your users, once they have explicitly selected a date, why would they want focus back on the same field? So instead set focus to the next input.

http://jsfiddle.net/QwQwN/

$(function() {
    $(".date").datepicker({ });
});

$('.date').change( function() {
    $(this).nextAll('input:first').focus();
});

我尝试使用日期选择器的onClose事件,但更改焦点中途打破了插件。我不认为这是可能的,如果不修改实际的插件代码。

I tried using the onClose events of the date picker, but changing focus midstream broke the plugin. I dont think this is possible without modifying the actual plugin code.

这篇关于防止打开日历的timepicker插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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