Jquery函数在web浏览器上工作,但在android设备上不工作
我有一个Phonegap应用程序,它不会加载一些JQuery和Mobiscroll脚本。在浏览器中,加载非常完美,但当我使用phonegap构建它并在设备上测试它时,它不会显示数据和时间滚动条,也不会显示添加一些jSON的按钮 我是网络应用程序开发和使用phonegap的新手,所以如果我犯了noob错误,请不要对我太苛刻 我还尝试了来自的Ellococoloco溶液,得到了相同的结果。我认为它与$(document).ready(function($)有关,因为当我删除函数paramater中的“$”时,它不会在web浏览器中加载 剧本如下Jquery函数在web浏览器上工作,但在android设备上不工作,jquery,jquery-mobile,cordova,Jquery,Jquery Mobile,Cordova,我有一个Phonegap应用程序,它不会加载一些JQuery和Mobiscroll脚本。在浏览器中,加载非常完美,但当我使用phonegap构建它并在设备上测试它时,它不会显示数据和时间滚动条,也不会显示添加一些jSON的按钮 我是网络应用程序开发和使用phonegap的新手,所以如果我犯了noob错误,请不要对我太苛刻 我还尝试了来自的Ellococoloco溶液,得到了相同的结果。我认为它与$(document).ready(function($)有关,因为当我删除函数paramater中的
$(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();
});
});
$(文档).ready(函数($){
var json='[{“productsArray”:[{“productName”:“Wine”,“productPrice”:“12”,“priceCurrency”:“Dollar”,“productDescription”:“非常好”}],“categoryName”:“饮料”},{“productsArray”:[{“productName”:“牛排”,“productPrice”:“12”,“priceCurrency”:“Dollar”,“productDescription”:“这是一个非常简短的描述”},{“productName”:“大蒜”,productPrice:“2”,“priceCurrency:“Dollar”,“productDescription:“Dracula”}],“categoryName:“Very good”}];
var obj=JSON&&JSON.parse(JSON)| | jQuery.parseJSON(JSON);
$(“#添加类别”)。单击(函数(){
对于(var j=0;j;
对于(var i=0;i
”);
}
类别HTML+='';
$('#menuHolder').append(categoryHTML).trigger(“create”);
$('#menuHolder').find('div[data role=collapsable]').collapsable();}
});
$('#demo').mobiscroll().date({
主题:“安卓ics灯光”,
显示:“底部”,
模式:“滚动条”,
onFocus:false,
是的,
无效:['w0','w6','5/1','12/24','12/25']
});
$(“#显示”)。单击(函数(){
$('demo').mobiscroll('show');
返回false;
});
$('#demo2').mobiscroll().time({
主题:“安卓ics灯光”,
显示:“内联”,
模式:“滚动条”,
分钟:15,
标题文字:false
});
$('#show2')。单击(函数(){
$('demo2').mobiscroll('show');
返回false;
});
$('#demo3')。mobiscroll()。选择({
主题:“安卓ics灯光”,
显示:“模态”,
动画:“流行音乐”,
模式:“滚动条”,
inputClass:'i-txt',
宽度:200
});
$('#show3')。单击(函数(){
$('demo3').mobiscroll('show');
返回false;
});
$('#清除')。单击(函数(){
$('#demo').val('');
$('demo2').val('');
$('#demo3').val(1).change();
$('demo3'+'u dummy').val('';
返回false;
});
$('#demo').focus(函数(){
这个。blur();
});
$('#demo2')。焦点(函数(){
这个。blur();
});
$('#demo3')。焦点(函数(){
这个。blur();
});
});
通过使用
jQuery(document).on('pageinit','#imenu', function () {
单击功能与
jQuery('#addCategory').live('tap', function () {
所有的选择器$都使用jQuery,因为我与另一个框架发生冲突,现在它可以在我的设备上完美地工作
.ready()
不应该在jQuery Mobile中使用,或者,使用pageinit
即用$(文档)包装代码。on('pageinit',function(){//code});
@Omar当我使用pageinit时,我的脚本甚至在web浏览器中也不会加载。我还使用prototype-1.7.1.js来切换某些div的可见性。如果我不像jQuery(document)那样使用它。ready(函数($)使用最新的jqm 1.3.2和jquery 1.9.1链接@Omar使它工作起来。感谢你为我指明了正确的方向不客气,祝你好运:)添加一个答案,让其他人受益。