2014-03-25 19 views
0

我一直在Apache cordova出現問題,如果我複製源代碼以從API獲取照片(底部是URL)在我的index.html它的工作原理是完美的,但是如果我將相同的源代碼複製到可從index.html中點擊鏈接的按鈕中訪問的second.html中,那麼在這種情況下它不起作用。Apache cordova示例API不工作,如果它不在index.html

它看起來像我不得不把所有的功能在index.html的,因爲我在最後一種情況下得到的錯誤是

Undefined reference error : function is not defined 
source: file :///android_asset/www/index.html 

那麼,如何解決這個問題?是否不可能在與索引不同的其他頁面中使用來自cordova的API?

非常感謝!我正在使用jquery mobile並將其導入index.html(我剛剛看到如果它把它拿出來然後一切正常!但我真的需要它,所以如果你能告訴我一個解決方案,我會真的欣賞它)

http://cordova.apache.org/docs/en/2.5.0/cordova_camera_camera.md.html

+0

[Application Error is a directory(file:///#android \ _asset/www/index.html)](http://stackoverflow.com/questions/15535382/application-error-is-a -directory-文件Android的資產WWW的指數HTML) –

回答

0

我有同樣的問題,當使用JQM和相機插上,我的應用程序不會工作。 我發現DeviceReady事件未被觸發。 這是

Undefined reference error : function is not defined 

首先的原因是: 而不是使用HREF =「otherPage.html」 我這樣做是調用第二頁:

<div data-role="content" class="ui-content"> 
    <a id="btnCamera" href="#" class="ui-btn">Go to camera</a> 
</div> 

,然後創建一個腳本來處理按鈕的點擊事件。

<script type="text/javascript"> 
     $("#btnCamera").bind("click", function(event) { 
      window.location.assign("otherPage.html"); 
      }); 

</script> 

此更改使第二頁觸發DeviceReady事件。

一切工作正常。