I've encounter a strange behavior with the jQueryUI DatePicker on my blog app. It shows up correctly when I compose a new post, but when I edit on an existing post, the Datapicker lost it styles and localization.The compose and edit actions share the same view.
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.4.4");
google.load("jqueryui", "1.8.9");
</script>
<script src="../../Scripts/jquery.ui.datepicker-zh-CN.js" type="text/javascript"></script>
<script>
$(function () {
$("#Date").datepicker($.datepicker.regional["zh-CN"]);
});
</script>
&开发者_运维问答lt;input id="Date" name="Date" type="text" value="@Model.Date" tabindex="2" style="width:100px" />
Here is action method when compose a new post
[Authorize]
public ActionResult Compose()
{
string date = DateTime.Now.ToString("yyyy-MM-dd");
return View(new BlogPostComposeModel { Date = date, Body = "", Title = "", Tags = "" });
}
Here is the action method when edit an existing post, this is when the Datepicker lost its styles and localization.
[Authorize]
public ActionResult Edit(string postID)
{
BlogPost post = // get post from data source
string date = post.DateCreated.ToString("yyyy-MM-dd");
return View("Compose", new BlogPostComposeModel { Date = date, Body = post.Body, Title = post.Title, Tags = tagNames });
}
Any chance using Url.Content help at all?
<script src='@Url.Content("~/Scripts/jquery.ui.datepicker-zh-CN.js")' type="text/javascript"></script>
And also for you css
<link href='@Url.Content("~/Content/themes/something.css")' rel="stylesheet" type="text/css" />
精彩评论