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;;}

發佈了13 篇原創文章 · 獲贊 6 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章