List basics & API
1.16 Calling the listview plugin
สามารถเรียกใช้ listview plugin บน selector อื่นๆ เช่นเดียวกับการเรียกใช้ปลั๊กอินของ jQuery
$('#mylist').listview();
1.17 Updating lists
สามารถเพิ่ม items ไปยัง listview โดยต้องเรียกใช้ method : refresh()เพื่อปรับปรุงรูปแบบ และสร้างรายการที่ซ้อนกัน เช่น
$('#mylist').listview('refresh');
หมายเหตุ: method refresh() จะมีผลต่อโหนดใหม่ผนวกเข้ากับรายการ(list)เท่านั้น
ในรายการใดที่ได้รับการปรับปรุงแล้วจะถูกละเว้น ซึ่งหมายความว่า ถ้าคุณเปลี่ยนเนื้อหาหรือ attributes
ของรายการที่ปรับปรุงไปแล้ว รายการนั้นจะไม่ปรากฎ หากต้องการปรับปรุง list item สามารถใส่ fresh markupก่อนที่จะเรียกใช้ method refresได้
และ สามารถเพิ่มclass: ui-screen-hidden ลงใน element :li ได้ ในกรณีที่ต้องการซ่อนlist item
1 Listviews Option
Listview plugin มี options ดังต่อไปนี้
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.countTheme = "a";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.dividerTheme = "a";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.filter = true;
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.filterCallback = function( text, searchValue )
{
// only show items that *begin* with the search string
return text.toLowerCase().substring( 0, searchValue.length ) !==
searchValue;
};});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.filterPlaceholder = "Search...";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.filterTheme = "a";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.headerTheme = "a";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.initSelector = ".mylistview";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.inset = true;
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.splitIcon = "star";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.splitTheme = "a";
});
$( document ).bind( "mobileinit", function(){
$.mobile.listview.prototype.options.theme = "a";
}
2 Listviews Medthod
Listview plugin มี method ดังต่อไปนี้
$('.selector').listview('childPages');
$('.selector').listview('refresh');
3 Listviews Events
Listview plugin มี events ดังต่อไปนี้
ผูก event ใน <ul> หรือ<ol> โดยใช้ virtual events หรือผูกกับ JavaScript events, like change, focus, blur ฯลฯ จากโค้ดดังต่อไปนี้
$( ".selector" ).listview({
create: function(event, ui) { ... }
});