我可以使用带有phonegap的jquery模板

时间:2016-11-25 13:41:44

标签: jquery cordova phonegap-cli

在我的phonegap项目中,我想使用jquery模板,我尝试了一个例子:

这是我的页面:

<html>  
<head>
...
    <script type="text/javascript" src="jquery.min.js"></script>        
    <script type="text/javascript" src="jquery.tmpl.js"></script>       
</head>
<body>    
    <script type="text/x-jQuery-tmpl" id="app_products">
        <div class="productsLIST">
            <div>
                <div class="image">
                    <div id='${productID}'></div>
                    <div >
                        <div class="image-detail"> <img src="${imgPath}" alt="Product" class="img-responsive"> </div>
                    </div>            
                    <div>
                        <p class="name">${product_name} </p>
                        <span class="price">${price} DT</span>
                    </div>
                </div>
            </div>
        </div>     
    </script>

    <div id="content"></div>    

    <script>
         var ws_url = "http://192.168.0.25:8080/services";
        $.ajax({
            type: 'GET',
            url : ws_url+'/request/getJsonData/125',
            data : {},
            dataType: 'json',
            error : function(jqXHR, exception) {},
            success : function(xhr){
                var jsonData = JSON.parse(JSON.stringify(xhr));
                if(jsonData != null && jsonData.length) {
                    $.each(jsonData, function(index, item) {
                        var _options = {};
                        $("#app_products").tmpl(item, _options).appendTo("#content");                   
                    });
                }       
            } 
        });
    </script>
</body>

此示例不适用于Android设备。 我不知道为什么。此代码适用于Web浏览器!

0 个答案:

没有答案