4

我使用了来自http://trentrichardson.com的 timepicker 插件

这里我有一个问题,在我选择日期后,Timepicker 弹出窗口没有关闭。

<asp:TextBox ID="datetimepicker" runat="server" CssClass="datetimepicker" >
</asp:TextBox>

jQuery

$(document).ready(function () {
    $('.datetimepicker').datetimepicker({});
});

现在它显示如下:

日期

所以在选择日期时,我希望它关闭。

4

1 回答 1

2

Sadly, this plugin prevents adding neat jQuery code for hiding.

It would be something like this:

$(document).on("click", ".ui-datepicker a", function() {
    $(this).closest(".ui-datepicker").hide();
});

But it prevevents propagation of click event and invoking other click handlers, so above doesn't work.

The below solution is in a bad style, but it works (http://jsfiddle.net/cL9Fx/1/):

$(document).ready(function () {
    $('#datetimepicker').datetimepicker({});
    $("#datetimepicker").click(function() {
        $(".ui-datepicker a").each(function(index, elem) {
            $(elem).attr("onclick", "$(this).closest(\".ui-datepicker\").fadeOut(\"fast\");");
        });
    });
});
于 2013-04-06T11:15:37.970 回答