2012-04-06 64 views
7

我正努力將Cordova(= Phonegap)與Ember.js和jQuery Mobile集成在一起。 Ember.js + jQuery Mobile工作正常,因爲在任何桌面瀏覽器中加載index.html都能成功加載應用程序。有沒有人成功集成了Ember.js - Phonegap(和jQuery Mobile)?

使用xCode 4和iPhone 5.1模擬器,它不會在車把標籤內顯示任何內容。這意味着Ember.js無法加載。

的index.html:

<html lang="en"> 
<head> 

    <title></title> 

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> 
    <meta charset="utf-8"> 

    <link rel="apple-touch-icon" href="/apple-touch-icon.png"> 

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" /> 

</head> 
<body> 
    <script type="text/x-handlebars" data-template-name="main"> 
    this text is NOT displayed 

    </script> 

    <div> this text IS displayed </div> 


    <script src="js/vendor/jquery.min.js"></script> 
    <script src="js/vendor/jquery.mobile.js"></script> 
    <script src="js/vendor/ember.js"></script> 
    <script src="js/app/app.js"></script> 
    <script src="js/vendor/cordova-1.5.0.js"></script> 
    <script type="text/javascript"> 

     // If you want to prevent dragging, uncomment this section 
     function preventBehavior(e){ 
      e.preventDefault(); 
     }; 
     document.addEventListener("touchmove", preventBehavior, false); 


     document.addEventListener("deviceready", onDeviceReady, false); 

     /* When this function is called, Cordova has been initialized and is ready to roll */ 
     /* If you are supporting your own protocol, the var invokeString will contain any arguments to the app launch. 
     see http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html 
     for more details -jm */ 
     function onDeviceReady(){ 
      // do your thing! 
     } 

    </script> 

</body> 
</html> 

回答

3

發現這個問題。 XCode中被報告:

ERROR whitelist rejection: url='http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css' 

this,我加*.jquery.comExternalHosts陣列,內Cordova.plist

+1

我會告訴你,如果你把你的jQuery依賴關係放在網絡連接上,你的應用將被拒絕。你可以使用網絡,但你需要有一些東西讓用戶知道爲什麼應用程序的一部分沒有工作,因爲他們沒有連接。 – 2012-04-06 18:38:18

+0

更正CSS - 雖然同樣的事情。你的應用需要加載這些文件才能被批准。 – 2012-04-06 19:04:14

+0

感謝您的提示。不知道的是,我打算讓應用完全脫機。 – 2012-04-06 21:07:47