开发者

MVC: How do you remove focus from a datepicker?

I have this Editor Template so that I have a datepicker set for date input. See

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" 开发者_如何学C%>
<%:Html.TextBox("", (Model.HasValue ? Model.Value.ToLongDateString() : string.Empty), 
    new { @class = "datePicker" })%>

When I load a page with a date input field I automatically get the datepicker invoked. I would rather wait until the user clicks on the field or button.

I am thinking that I want to use a JQuery Blur command associated with this Editor Template to stop this happening. But is that the right way, can it be done like that, or is there a better way?


If you don't want the calendar to appear until something is clicked, then you can try the showOn option, possibly like:

$(document).ready(function () {
    $(".datepicker").datepicker({
        showOn: "button",
        buttonImage: "/images/calendar.gif",
        buttonImageOnly: true,
        buttonText: 'Calendar'
    });
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜