1

有很多问题和答案,但我找不到我要找的东西。

我通过链接单击显示日期选择器,但当用户选择日期时无法隐藏它。如果您有任何建议,请告诉我。您可以在http://jsfiddle.net/5qE8K/找到相关代码

    $("#calendar > a").unbind('click').bind('click', function(e){
        e.preventDefault();

        var calendar = $(this).parent();

        $("#content").datepicker({
            beforeShow: function(){
                $(".ui-datepicker").css({
                    'position'  :   'absolute',
                    'top'       :   (calendar.offset().top + calendar.height() + 4) + 'px',
                    'left'      :   (calendar.offset().left + calendar.width() - $(".ui-datepicker").outerWidth(true)) + 'px'
                });
            },
            onSelect: function(date, obj){
                calendar.children("div#selected-date").text(obj.selectedDay + '/' + (obj.selectedMonth+1) + '/' + obj.selectedYear);
                calendar.children("span").text(obj.selectedDay);
                $("#content").datepicker('hide');
            }
        });
    });
4

1 回答 1

0

在内联detepicker(即附加到输入以外的元素的日期选择器)上调用“隐藏”没有任何作用。尝试调用破坏。

// ...
calendar.children("span").text(obj.selectedDay);
$("#content").datepicker('destroy');
// ...
于 2012-10-16T22:01:47.617 回答