阻止jquery-ui datepicker显示在beforeShow中 [英] Stop jquery-ui datepicker from showing in beforeShow

查看:76
本文介绍了阻止jquery-ui datepicker显示在beforeShow中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做这样的事情:

var showme = false;

$('#mydatepicker').datepicker({
    beforeShow: function(input, inst) {
        if(!showme) {
            //stop showing
        }
    }
});

但是禁用,隐藏也不起作用.我想做一些类似于preventDefault的工作,但是我认为在这种情况下它不会起作用.

But disable, nor hide seems to work. I'd like to do something that works like preventDefault, but I don't think it'll work in this case.

推荐答案

从源头看,目前看来不可能.您也许可以要求将其作为一项功能.如果确实要使其停止(尽管这可能是个坏主意),则可以在该函数中引发错误.尽管这会导致您的页面显示错误,并且可能不是选择.

Looking through the source, it doesn't look like that is possible currently. You might be able to request that as a feature. If you really want to make it stop (though this is probably a bad idea) you could throw an error in that function. Though this will cause errors to show up for your page and probably is not an option.

注意:我为此提交了一个补丁,现在已发布在jQuery UI中(最低 v1.9及更高版本),尽管文档中未提及它. beforeShow中的return false将阻止日期选择器出现(现在).

Note: I submitted a patch for this and it's now in the released jQuery UI (at least v1.9 and later), although the documentation doesn't mention it. return false in beforeShow will prevent the datepicker from appearing (now).

这篇关于阻止jquery-ui datepicker显示在beforeShow中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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