gpt4 book ai didi

Jquery 函数适用于网络浏览器,但不适用于 Android 设备

转载 作者:行者123 更新时间:2023-12-01 04:12:17 25 4
gpt4 key购买 nike

我有一个 Phonegap 应用程序,它不会加载某些 JQuery 和 Mobiscroll 脚本。在浏览器中加载完美,但是当我使用phonegap构建它并在设备上测试它时,它没有向我显示数据和时间滚动条以及添加一些json的按钮。

我是网络应用程序构建和使用phonegap的新手,所以如果我犯了菜鸟错误,请不要对我太严厉......

我还尝试了 Phonegap not calling device ready function 中的 ElLocoCocoLoco 解决方案我得到了同样的结果。我认为它与 $(document).ready(function($) 有关,因为当我删除函数参数中的“$”时,它也不会在网络浏览器中加载

脚本如下

$(document).ready(function($) {
var json = '[{"productsArray":[{"productName":"Wine","productPrice":"12 ","priceCurrency":"Dollar ","productDescription":" Very good "}],"categoryName":"Drinks"},{"productsArray":[{"productName":"Steak","productPrice":"12 ","priceCurrency":"Dollar ","productDescription":" This is a very short description "},{"productName":"Garlic","productPrice":"2 ","priceCurrency":"Dollar ","productDescription":" Dracula "}],"categoryName":"Very good food"}]';
var obj = JSON && JSON.parse(json) || jQuery.parseJSON(json);



$('#addCategory').click(function () {
for (var j = 0; j < obj.length ;j ++) {
var categoryHTML='<div data-role="collapsible" data-collapsed="true"><h2>'+ obj[j].categoryName +'</h2><ul data-role="listview" data-split-icon="plus" data-theme="a" data-split-theme="b" data-inset="true" >';
for (var i = 0; i < obj[j].productsArray.length ;i++) {
categoryHTML += ('<li> <a href="#" onclick="showMe(\'cat-ex\')"> <h3>'+ obj[j].productsArray[i].productName +'</h3> \
<p><strong> '+ obj[j].productsArray[i].productDescription +'</strong> </p>\
<span class="ui-li-count"><strong>'+ obj[j].productsArray[i].productPrice +'</strong>LEI</span> \
</a><a href="#" style="margin-top:0px;" onClick="alert(\'Comanda a fost plasata!\')" data-rel="popup" data-transition="pop">Plateste</a><br></li>');
}
categoryHTML += '</ul></div>';

$('#menuHolder').append(categoryHTML).trigger("create");
$('#menuHolder').find('div[data-role=collapsible]').collapsible();}
});

$('#demo').mobiscroll().date({
theme: 'android-ics light',
display: 'bottom',
mode: 'scroller',
onFocus: false,
onTouch: true,
invalid: [ 'w0', 'w6', '5/1', '12/24', '12/25' ]

});
$('#show').click(function(){
$('#demo').mobiscroll('show');
return false;
});


$('#demo2').mobiscroll().time({
theme: 'android-ics light',
display: 'inline',

mode: 'scroller',
stepMinute: 15,
headerText: false
});
$('#show2').click(function(){
$('#demo2').mobiscroll('show');
return false;
});


$('#demo3').mobiscroll().select({
theme: 'android-ics light',
display: 'modal',
animate: 'pop',
mode: 'scroller',
inputClass: 'i-txt',
width: 200
});
$('#show3').click(function () {
$('#demo3').mobiscroll('show');
return false;
});
$('#clear').click(function () {
$('#demo').val('');
$('#demo2').val('');
$('#demo3').val(1).change();
$('#demo3'+'_dummy').val('');
return false;
});

$('#demo').focus(function() {
this.blur();
});
$('#demo2').focus(function() {
this.blur();
});
$('#demo3').focus(function() {
this.blur();
});
});

最佳答案

通过更改 init 使其工作

jQuery(document).on('pageinit','#imenu', function () {

点击功能

jQuery('#addCategory').live('tap', function () {

以及所有选择器$jQuery,因为我与另一个框架发生了冲突,现在它在我的设备上完美运行

关于Jquery 函数适用于网络浏览器,但不适用于 Android 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18917314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com