Search code examples
asp.net-mvc-2wijmo

wijmo date picker using in textbox


I need examples for using the wijmo date picker in a text box. I am having trouble in using wijmo date picker. It is working when I am using in div but not in textbox

here is my code:

<%:  Html.TextBox("sample")%>

$(document).ready(function () {
    $("#sample").wijcalendar({ 
        easing: 'easeInQuad' 
    });
});

Solution

  • You still need the div for the calendar itself, but then attach the calendar show option to the input.

    <%: Html.TextBox("sample")%>    
    <div id="calendar"></div>
    $("#calendar").wijcalendar({
        popupMode: true,
        selectedDatesChanged: function () {
            var selDate = $(this).wijcalendar("getSelectedDate");
            if (!!selDate) $("#sample").val(selDate.toDateString());
        }
    });
    
    $("#sample").click(function () {
            $("#calendar").wijcalendar("popup", {
                of: $("#sample"),
                offset: '0 2'
            });
        })
    });