phoneGap&jquery mobile

访问外部url,需要在PhoneGap.plist中ExternalHosts中添加域名,注意,不要把协议和路劲加进来。

若使用第三方phonegap插件(https://github.com/phonegap/phonegap-plugins),需在PhoneGap.plist中Plugins中添加对应项。

数据加载:

$.ajax({

url:"http://www.XXX.XXX",

async:true,//异步

cache:false,

type:"Get",

dataType:"json",

timeout:5000,

error:function(data){},

success:

function(data){

$.each(data,function(i,field){

$("ul").append("<li>"+filed.name+"</li>");

})

}

,

complte:function(data){}

})


最后刷新listview:  $("ul").listview("refresh")。


1、更改ul后要使用listview('refresh')刷新视图;

$('ul').append('<li>row</li>').listview('refresh');


2、选取header,并绑定双击事件
$("[data-role='header']").bind('dblclick',function(e){});


3、定时变换背景,长按为taphold
$('#txt').tap(function(){
var elem = this;
$(elem).css('background','yellow');
setTimeout(function(){$(elem).css('background','transparent');},2000);
});
});


4、取消Ajax链接
页面默认为Ajax链接,要把它禁用,有三种方法
A、<a href="second.html" data-ajax="false">Second</a>
B、rel="external"
C、$.mobile.ajaxEnabled=false;


5、图标data-icon类型
home | delete | plus | arrow-u | arrow-d |  arrow-r | arrow-l|check | gear | grid | star | custom  | minus | refresh | forward | back | alert | info | search


6、Button大小
默认为屏幕同宽,若要变小使用data-inline="true"


7、只有图标的按钮
添加data-iconpos="notext"


8、使buttom在header右方

class="ui-btn-right"


9、设置<li class="span">有惊喜,转个不停。


10、固定页面:document.addEvenListener('touchmove',function(e){e.preventDefault();},false);


11、phoneGap中报错ERROR whitelist rejection: url

在PhoneGap.plist里,ExternalHosts加个域名,注意不要协议头,不要路劲和文件名,只要域名(如www.baidu.com)。


12、取消字段截断

button中

.ui-btn-text{

white-space:normal;}

list中

.ui-li-desc{

white-space:normal;}


13、禁用button

$('#home-button').button('disable');


14、去除list中的箭头

<li data-icon="false"><a>row</a></li>


15、设置页面背景颜色

.ui-page{

background:#eee;;}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值