jQuery Datepicker-选择日期后保持打开状态,并使用“完成"按钮关闭 [英] jQuery Datepicker - keep open after selecting a date and close with the button "Done"

查看:360
本文介绍了jQuery Datepicker-选择日期后保持打开状态,并使用“完成"按钮关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

老实说,我希望您能为我提供帮助,因为我花了很多时间在网上搜索适当的解决方案,但找不到任何解决方案.

I honestly hope you can help me with that as I have spent quite some time searching on the net for appropriate solutions and could not find any.

我遇到的问题是我有一个jQuery datepicker,我希望在选择一个日期后保持打开状态,然后单击其下方的完成"按钮将其关闭.我发现的最接近的东西来自 StackOverflow答案从2012年开始,但不幸的是,它隐藏了showButtonPanel: true选项中的按钮.

The issue I am having is that I have a jQuery datepicker which I would like to keep open after selecting a date and then close it when clicking the button "Done" underneath it. The closest thing I found is coming from a StackOverflow answer from 2012, but unfortunately it hides the buttons coming from the showButtonPanel: true option.

所以这是我最新的尝试"的快照,再次无法使用:

So this is a snapshot of my latest "try" which again it doesn't work:

$(function() {
  $(".datepicker").datepicker({
    showButtonPanel: true,
    onSelect: function(){
      $(this).val();
    }
  });
});

日历是从以下位置触发的:

The calendar gets triggered from:

<input class="datepicker" type="text" path="startDate" data-date-format="mm/dd/yyyy" />

仅供参考-我正在使用jQuery 1.7.2.min.js(不幸的是,出于安全性考虑,我无法更新),jQuery-ui 1.10.3,当然还有Bootstrap(3.0.3版,尽管我不确定是否可以会有所帮助). 谢谢

FYI - Im using jQuery 1.7.2.min.js (unfortunately I cannot update for safety and security reasons), jQuery-ui 1.10.3 and of course, Bootstrap (version 3.0.3 although I am not sure if this will help). Thank you

推荐答案

这是一个有效的小提琴: http://jsfiddle.net/9uc7dwoa/

Here is a working fiddle: http://jsfiddle.net/9uc7dwoa/

这是onSelect中的技巧:

This is doing the trick in the onSelect:

if (inst.inline)
        this._updateDatepicker(inst);
else {
      this._hideDatepicker(null, this._get(inst, 'duration'));
      this._lastInput = inst.input[0];
      if (typeof(inst.input[0]) != 'object')
      inst.input[0].focus(); // restore focus
      this._lastInput = null;
}

以下是使用所用代码的答案参考: jQuery Datepicker:防止在单击日期时关闭选择器

Here the reference of the answer with the used code: jQuery Datepicker: Prevent closing picker when clicking a date

这篇关于jQuery Datepicker-选择日期后保持打开状态,并使用“完成"按钮关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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