jQueryMobile Datebox 不会采用默认日期值 - 尝试了一切

发布于 2024-12-26 18:30:11 字数 1821 浏览 2 评论 0原文

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

我非常感谢专家的帮助。

谢谢

I am trying to open a jQueryMobile datebox in a dialog mode. I am trying to set the datebox to a default value but it just won't take it for some reason. Here is my code:

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

I would really appreciate help from experts.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

筱武穆 2025-01-02 18:30:11

这应该可以做到:

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

This should do it:

$('#myqdate').trigger('datebox', {'method':'set', 'value':'2012-01-14', 'date':new Date('2012-01-14')})
夏天碎花小短裙 2025-01-02 18:30:11

看来您应该使用“defaultValue”属性,而不是发布代码的数据选项中的“defaultDate”。不需要脚本块。

It seems that you should be using the "defaultValue" property instead of the "defaultDate" that is in the data-options of your posted code. No need for the script block.

你好,陌生人 2025-01-02 18:30:11

尝试关闭你的函数:
$('文档').ready(function(){
//设置页面加载的开始日期值
$('#myqdate').value('2012-01-14');
$('#myqdate').datebox('刷新');
}
)};

try closing your function:
$('document').ready(function(){
//Setting start date value on pageload
$('#myqdate').value('2012-01-14');
$('#myqdate').datebox('refresh');
}
)};

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文