c# - jQuery Mobile Datebox 不会采用默认日期值 - 尝试了所有方法

标签 c# jquery mobile razor webmatrix

我正在尝试以对话框模式打开 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>

我非常感谢专家的帮助。

谢谢

最佳答案

这应该可以做到:

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

关于c# - jQuery Mobile Datebox 不会采用默认日期值 - 尝试了所有方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8861841/

相关文章:

jQuery 开关类未在 Chrome 中正确激活

jquery - 为什么 $(document).height() 与 $(document.body).height() 不同?

jquery - pageinit 和 pageshow 之间的区别

javascript - 在移动设备上重新加载上一页的 JavaScript

c# - 如何使用先前输入的参数重新加载页面?

c# - 继承的 C# 类丢失 "Reference"

c# - 如何解决变成 "ASPx is not defined"异常的 "potentially dangerous Request.Path"错误?

jquery-plugins - 可访问的,适合移动设备的灯箱?

c# - 我们如何使用 FtpWebRequest 显示上传进度条

c# - Control.Focus() 错误