beforeShow事件没有在jQueryUI Datepicker上触发 [英] beforeShow event not firing on jQueryUI Datepicker

查看:128
本文介绍了beforeShow事件没有在jQueryUI Datepicker上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我尝试什么,我都无法获得beforeShow事件在我的datepicker上触发。这是我的代码:

No matter what I try, I'm not able to get the beforeShow event to fire on my datepicker. Here's my code:

$('#calendar').datepicker({
inline: true,
dateFormat: 'mm,dd,yy',
beforeShow: function(input, inst) { alert('before'); }
});

我已将beforeShowDay和onSelect事件添加到我的datepicker,并且它们正确启动。有人有麻烦吗?

I've added beforeShowDay and onSelect events to my datepicker, and they do fire correctly. Has anyone else had trouble with this?

推荐答案

这是我的团队提出的解决方案,所以我们不必记得每次有更新时修改jQuery文件。只需将其添加到您自己的脚本中,并将其包含:

Here's the solution my team came up with so we don't have to remember to modify the jQuery files every time there's an update. Just add this to your own script and include it:

(function ($) {
    $.extend($.datepicker, {

        // Reference the orignal function so we can override it and call it later
        _inlineDatepicker2: $.datepicker._inlineDatepicker,

        // Override the _inlineDatepicker method
        _inlineDatepicker: function (target, inst) {

            // Call the original
            this._inlineDatepicker2(target, inst);

            var beforeShow = $.datepicker._get(inst, 'beforeShow');

            if (beforeShow) {
                beforeShow.apply(target, [target, inst]);
            }
        }
    });
}(jQuery));

这篇关于beforeShow事件没有在jQueryUI Datepicker上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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