CSMJU jQuery Mobile

เมนู
ถัดไป ก่อนหน้า

3.1 Pages & dialogs

       n. PhoneGap apps

การBuilding PhoneGap (Cordova) แอปด้วย jQuery Mobile
   PhoneGap เป็นแพลตฟอร์มแอปพิเคชัน HTML5 ที่ช่วยให้นักพัฒนาได้พัฒนาเว็บแอปพลิเคชันด้วยเทคโนโลยีที่เข้าถึง APIs และ app stroes Phone Gap jQuery Mobile แอปพลิเคชันจะควบคมโดยสองสิ่งนี้คือ $.support.cors และ $.mobile.allowCrossDomainPages
$.support.cors
ตัวอย่าง

ส่งค่ากลับในรูปแบบของ box สำหรับ iframe

ผลลัพท์
This frame uses the W3C box model:true
ตัวอย่างโค้ด

   <!DOCTYPE html>
<html><head>
<style>
p { color:blue; margin:20px; }
span { color:red; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head><body><script>
$("p").html("This frame uses the W3C box model: <span>" +jQuery.support.boxModel + "</span>");</script>
</body>
</html>
   

$.mobile.allowCrossDomainPages
   เมื่อ jQuery Mobile พยายามโหลดหน้าเพจภายนอก จะเรียกผ่าน $.mobile.loadPage() แต่สามารถเรียกข้ามโดเมนได้โดย $.mobile.allowCrossDomainPages กำหนดค่าให้เป็น ture
ตัวอย่าง


$( document ).bind( "mobileinit", function() {
    // Make your jQuery Mobile framework configuration changes here!
    $.mobile.allowCrossDomainPages = true;
});

เคล็ดลับอื่นๆ

super.setIntegerProperty("loadUrlTimeoutValue", 60000);

Building UIWebView apps with jQuery Mobile
ตัวอย่าง


- (void)viewDidLoad{
    [super viewDidLoad];
    NSString *fullURL = [[NSBundle mainBundle] pathForResource:@"dialog" ofType:@"html"];
    NSURL *url = [NSURL fileURLWithPath:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];}