如何使用jquery mobile设置默认当前日期?

时间:2013-07-19 08:27:58

标签: jquery-mobile

你能告诉我如何在文本字段上设置默认日期。实际上我有一个按钮点击弹出屏幕显示有日期字段i显示当前日期的日期。

  <div data-role="popup" id="CaseInformationScreen" data-close-btn="none"  data-overlay-theme="a" data-dismissible="false">
                <div data-role="header" data-theme="b" >

                    <a href="#" data-role="button" data-corners="false" id="Cancel">Cancel</a>
                    <h1>Case Information</h1>
                    <a href="#" data-role="button" data-corners="false" id="AddButton">Add</a>
                </div>

                <div data-role="content">
                    <div><img src="img/Documents.png"/></div>
                    <div data-role="fieldcontain">
                        <label for="text-12" style="text-align:top;margin-left: 0px;">Case Name:</label>
                        <input name="text-12" id="text-12" value="" type="text" class="caseName_h" autocorrect="off">
                    </div>
                    <div data-role="fieldcontain">
                        <label for="caseDate" style="text-align:left;margin-left: 0px;" >Case Date:</label>
                        <input name="caseDate" id="caseDate" value="" type="date" class="caseDate_h" >
                           <!--input name="mydate2" id="mydate2" type="date" data-role="datebox" class="caseDate_h" data-options='{"mode": "calbox","useNewStyle":true,"zindex":1200}'/-->
                    </div>
                    <div data-role="fieldcontain">
                        <label for="textarea-12">Case Notes :</label>
                        <textarea cols="40" rows="8" name="textarea-12" id="text-12" class="caseTextArea_h" autocorrect="off"></textarea>
                    </div>
                </div>
            </div>

2 个答案:

答案 0 :(得分:1)

工作示例:http://jsfiddle.net/Gajotres/Ndc2b/

HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>jQM Complex Demo</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
        <!--<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>-->
        <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>    
    </head>
    <body>
        <div data-role="page" id="index">
            <div data-theme="b" data-role="header">
                <h1>Index page</h1>
            </div>

            <div data-role="content">
                <a href="#CaseInformationScreen" data-rel="popup" data-role="button" data-inline="true" data-transition="pop">Basic Popup</a>
                <div data-role="popup" id="CaseInformationScreen" data-close-btn="none"  data-overlay-theme="a" data-dismissible="false">
                    <div data-role="header" data-theme="b" >

                        <a href="#" data-role="button" data-corners="false" id="Cancel">Cancel</a>
                        <h1>Case Information</h1>
                        <a href="#" data-role="button" data-corners="false" id="AddButton">Add</a>
                    </div>

                    <div data-role="content">
                        <div><img src="img/Documents.png"/></div>
                        <div data-role="fieldcontain">
                            <label for="text-12" style="text-align:top;margin-left: 0px;">Case Name:</label>
                            <input name="text-12" id="text-12" value="" type="text" class="caseName_h" autocorrect="off"/>
                        </div>
                        <div data-role="fieldcontain">
                            <label for="caseDate" style="text-align:left;margin-left: 0px;" >Case Date:</label>
                            <input name="caseDate" id="caseDate" value="" type="date" class="caseDate_h" />

                        </div>
                        <div data-role="fieldcontain">
                            <label for="textarea-12">Case Notes :</label>
                            <textarea cols="40" rows="8" name="textarea-12" id="text-12" class="caseTextArea_h" autocorrect="off"></textarea>
                        </div>
                    </div>
                </div>                    
            </div>
        </div>    
    </body>
</html>   

Javascript:

$(document).on('pagebeforeshow', '#index', function(){ 
    $(document).on( "popupafteropen", "#CaseInformationScreen",function( event, ui ) {
        var today = new Date();   
        var dd = today.getDate();
        var mm = today.getMonth()+1; //January is 0!

        var yyyy = today.getFullYear();    

        $('#caseDate').val(dd + '-' + mm + '-' + yyyy);    
    });        
});

答案 1 :(得分:-1)

有一个非常简单的解决方案 这就是我所做的:

title_principals["all"] = title_principals["Actor1"].astype(str)+','+title_principals["Actor2"].astype(str)+','+title_principals["Actor3"].astype(str)+','+title_principals["Actor4"].astype(str)+','+title_principals["Actor5"].astype(str)+','+title_principals["Actor6"].astype(str)+','+title_principals["Actor7"].astype(str)+','+title_principals["Actor8"].astype(str)+','+title_principals["Actor9"].astype(str)+','+title_principals["Actor10"].astype(str)
相关问题