jQueryMobile Datebox赢得';t采用默认日期值-已尝试所有操作

本文关键字:操作 日期 默认 赢得 Datebox jQueryMobile | 更新日期: 2023-09-27 18:20:28

我正在尝试以对话框模式打开jQueryMobile日期框。我试图将日期框设置为默认值,但由于某种原因,它无法使用。这是我的代码:

<!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>

我真的很感谢专家们的帮助。

感谢

jQueryMobile Datebox赢得';t采用默认日期值-已尝试所有操作

这应该做到:

$('#myqdate').trigger('datebox', {'method':'set', 'value':'2012-01-14', 'date':new Date('2012-01-14')})

似乎应该使用"defaultValue"属性,而不是发布代码的数据选项中的"defaultDate"。不需要脚本块。

尝试关闭您的函数:$('document').ready(function(){ //Setting start date value on pageload $('#myqdate').value('2012-01-14'); $('#myqdate').datebox('refresh'); } )};