Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery Mobile根据Datepicker值获取Json数据_Jquery_Json_Cordova_Jquery Mobile_Jquery Ui Datepicker - Fatal编程技术网

JQuery Mobile根据Datepicker值获取Json数据

JQuery Mobile根据Datepicker值获取Json数据,jquery,json,cordova,jquery-mobile,jquery-ui-datepicker,Jquery,Json,Cordova,Jquery Mobile,Jquery Ui Datepicker,我在做phonegap项目。我使用jqm框架来实现它。 我有一个web api服务来将数据导入我的移动应用程序,这里我想在这个项目上使用Jquery mobile Datepicker 很快,我需要根据选择的日期获取数据 比如这里, 有没有像让输入自动回发,让程序根据文本框值获取数据这样的用法 我也在这里读过, 有什么例子可以让我检查吗?我在谷歌上搜索了一下,但看不到像我所想的那样的例子 谢谢。这里有一个工作示例: 我已经从我的示例中删除了JSON,因为它是一个私有数据 HTML: <!D

我在做phonegap项目。我使用jqm框架来实现它。 我有一个web api服务来将数据导入我的移动应用程序,这里我想在这个项目上使用Jquery mobile Datepicker

很快,我需要根据选择的日期获取数据

比如这里,

有没有像让输入自动回发,让程序根据文本框值获取数据这样的用法

我也在这里读过,

有什么例子可以让我检查吗?我在谷歌上搜索了一下,但看不到像我所想的那样的例子


谢谢。

这里有一个工作示例:

我已经从我的示例中删除了JSON,因为它是一个私有数据

HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>jQM Complex Demo</title>
        <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/ui/1.10.3/themes/smoothness/jquery-ui.css" />        
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>          
        <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>      
    </head>
    <body>
        <div data-role="page" id="index">
            <div data-theme="a" data-role="header">
                <h3>
                    First Page
                </h3>
            </div>

            <div data-role="content">
                <p>Date: <input type="text" id="datepicker" /></p>                
            </div>
        </div>  
        <div data-role="page" id="info">
            <div data-theme="a" data-role="header">
                <h3>
                    Info
                </h3>
                <a href="#index" class="ui-btn-left">Back</a>
            </div>

            <div data-role="content">

            </div>
        </div>         
    </body>
</html>   
$(document).on('pageinit', '#index', function(){       
    $( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd', 
        onSelect: function(date, instance) {
            selectedDate.date = date;
            $.mobile.changePage( "#info", {
                transition: "slide",
                reverse: false,
                changeHash: false
            });            
        } 
    });
});

$(document).on('pagebeforecreate', '#info', function(){    
    var json = $.parseJSON(dateHandler.json);
    $.each(json.Dates, function(id,date) {
        console.log(date.Date + '-' + selectedDate.date);
        var patt = new RegExp(selectedDate.date); 
        if(patt.test(date.Date)) {
            $('#info [data-role="content"]').append(JSON.stringify(date.Date)); 
        }
    });
});    

var selectedDate = {
    date : null
}

var dateHandler = {
    json : ''
}