更改jQuery Mobile日期选择器选项 [英] Changing jQuery Mobile date picker options

查看:154
本文介绍了更改jQuery Mobile日期选择器选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery Mobile日期选择器控件,但我无法更改任何属性。例如,以下代码将尝试将一周中的第一天设置为星期三,在文档就绪功能中,但不起作用。

 <!DOCTYPE html> 
< html>
< head>
< title>测试< / title>
< link rel =stylesheethref =jquery.mobile-1.0a4.1.min.css/>
< link rel =stylesheethref =jquery.ui.datepicker.mobile.css/>
< script type =text / javascriptsrc =jquery-1.5.2.min.js>< / script>
< script type =text / javascriptsrc =jquery.mobile-1.0a4.1.min.js>< / script>
< script src =jquery.ui.datepicker.js>< / script>
< script src =jquery.ui.datepicker.mobile.js>< / script>

< script>
$(document).ready(function()
{
$(#date)。datepicker({firstDay:3});
});
< / script>
< / head>
< body>
< div data-role =pagedata-theme =bid =home>
< div data-role =header>
< h1>测试< / h1>
< / div>
< div data-role =contentdata-theme =b>
< div data-role =fieldcontain>
< input type =datename =dateid =datevalue =/>
< / div>
< / div>
< / div>
< / body>
< / html>

任何想法我做错了什么?因为日期选择器已经被显示,这是不是有效?

解决方案

我已经设法改变了通过更改属性jquery.ui.datepicker.mobile.js文件



将日期格式更改为:dd / mm / yy代码如下

  //绑定到pagecreate以自动增强日期输入
$(.ui-page).live(pagecreate,function ){
$(input [type ='date'],input [data-type ='date']).each(function(){
$(this) ///)); $ b(alt) $ b});
});


I am using the jQuery Mobile date picker control but I cannot change any of the properties. For example, the following code will attempt to set the first day of the week to Wednesday, in the document ready function but it doesn't work.

<!DOCTYPE html> 
<html> 
    <head> 
        <title>Test</title> 
        <link rel="stylesheet" href="jquery.mobile-1.0a4.1.min.css" />
        <link rel="stylesheet" href="jquery.ui.datepicker.mobile.css" /> 
        <script type="text/javascript" src="jquery-1.5.2.min.js"></script>
        <script type="text/javascript" src="jquery.mobile-1.0a4.1.min.js"></script>
        <script src="jquery.ui.datepicker.js"></script>
        <script src="jquery.ui.datepicker.mobile.js"></script>

        <script> 
        $(document).ready(function()
        {
            $("#date").datepicker({ firstDay: 3 });
        });
        </script>       
    </head> 
    <body>
    <div data-role="page" data-theme="b" id="home">
        <div data-role="header">
            <h1>Test</h1>
        </div>
        <div data-role="content" data-theme="b">
            <div data-role="fieldcontain">
                <input type="date" name="date" id="date" value="" />
            </div>
        </div>
    </div>
    </body>
</html>

Any ideas what I'm doing wrong? Is this failing to work because the date picker is already displayed?

解决方案

I have managed to change to change the properties by changing the "jquery.ui.datepicker.mobile.js" file

To change the date format to : "dd/mm/yy" Code shown below

//bind to pagecreate to automatically enhance date inputs   
$( ".ui-page" ).live( "pagecreate", function(){     
    $( "input[type='date'], input[data-type='date']" ).each(function(){
        $(this).after($("<div />").datepicker({ altField: "#" + $(this).attr("id"), showOtherMonths: true, dateFormat: "dd/mm/yy" }));
    }); 
});

这篇关于更改jQuery Mobile日期选择器选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆