jQuery UI datepicker - add static text underneath the calendar?

后端 未结 3 799
长情又很酷
长情又很酷 2020-12-21 16:22

This is on the one that pops up when you click the linked input element. I want to be able to insert some static text underneath the table of dates that will appear and stay

3条回答
  •  不知归路
    2020-12-21 16:31

    To get around your "hacky" setTimeout workaround, you can attach click event handlers to the prev and next buttons. Here's code adapted from Martin's answer.

    $(function() {
        function appendText(text) {
            $('.ui-datepicker-calendar').after(''+lastText+'');
        }
    
        function addClickHandlers() {
            $('.ui-datepicker-prev, .ui-datepicker-next')
                .on('click', function() {
                    addClickHandlers();
                    appendText();
                });
        }
    
        var lastText;
        $( ".datepicker" ).datepicker()
            .on( "click", function() {
                lastText = $( this ).data('dptxt');
                appendText();
                addClickHandlers();
            });
    });
    

提交回复
热议问题