beforeShow event not firing on jQueryUI Datepicker

后端 未结 6 960
你的背包
你的背包 2020-12-05 18:00

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,
dateF         


        
6条回答
  •  无人及你
    2020-12-05 18:48

    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));
    

提交回复
热议问题