我想在對話框模式下打開jQueryMobile日期框。我正在嘗試將日期框設置爲默認值,但由於某些原因它不會採用它。這裏是我的代碼:jQueryMobile Datebox不會採用默認日期值 - 嘗試所有內容
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>@PageData["Title"]</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.css" />
<link rel="stylesheet" href="@Href("/Styles/theme/mysite.min.css")" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<script src="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/i8n/jquery.mobile.datebox.i8n.en.js"></script>
</head>
<body>
<script type="text/javascript">
$('document').ready(function(){
//Setting start date value on pageload
$('#myqdate').value('2012-01-14');
$('#myqdate').datebox('refresh');
}
</script>
<form name="shiftform" id="shiftform" action="@Href("~/Account/QChanges.cshtml")" method="post">
<div data-role="fieldcontain">
<label for="myqdate">Date:</label>
<input name="myqdate" id="myqdate" type="date" value="" data-role="datebox" data-options='{"mode": "flipbox", "forceInheritTheme": true, "defaultDate":"2012-01-14"}'>
</div>
<input type="submit" value="Get Queue"/>
</form>
</body>
</html>
我真的很感謝專家的幫助。
感謝
非常感謝離子,我應該在哪裏放置這行代碼?我應該用我的代碼替換這個東西嗎? – user1142216 2012-01-14 18:26:24
替換 '$('#myqdate')。value('2012-01-14'); $('#myqdate')。datebox('refresh');'帶上面的代碼。 – 2012-01-15 13:58:38
這也沒有工作離子。但我嘗試了一些非常簡單的方法,它似乎可行。我完全刪除了自定義JavaScript代碼,並簡單地將日期框代碼更改爲: – user1142216 2012-01-15 18:01:17