2014-09-29 51 views
0

我想動態更改div的內容。 我的HTML頁面看起來莫名其妙地喜歡這個IBM Worklight V6.1 jquery mobile v1.4.3更改動態內容,等待DOM

<!DOCTYPE HTML> 
<html> 
... 
<body> 
    <div data-role="page"> 
     <div data-role="header"> 
     //Image 
     </div> 

     <!-- This is a placeholder for dynamic page content --> 
     <div id="pagePort"></div> 
    </div> 
</body> 
</html> 
在wlCommonInit

()我稱之爲:

$("#pagePort").load("page2.html", function(){ 
}); 

,並沒有發生,但如果我有一個超時它工作正常。所以我的直覺是,我必須等待div準備好了嗎?
但是,我可以等待哪個事件來調用.load()語句?

回答

0

我無法複製您的聲明。

我在Worklight 6.1.0.01-20140821-0406(這實際上是6.1.0.2)和6.2.0.00-20140918-1910中都測試了以下內容,並且在顯示應用程序時立即加載了page2.html同時通過工作燈控制檯預覽吧:

的index.html:

<!DOCTYPE HTML> 
<html> 
     <head> 
      <meta charset="UTF-8"> 
      <title>index</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"> 
      <link rel="shortcut icon" href="images/favicon.png"> 
      <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
      <link href="jqueryMobile/jquery.mobile-1.4.4.css" rel="stylesheet"> 
      <link rel="stylesheet" href="css/main.css"> 
      <script>window.$ = window.jQuery = WLJQ;</script> 
      <script src="jqueryMobile/jquery.mobile-1.4.4.js"></script> 
     </head> 
     <body style="display: none;"> 
      <div data-role="page" id="page"> 
       <div data-role="content" style="padding: 15px"> 
        <div data-role="header"> 
        Header 
        </div> 
        <div id="pagePort"></div> 
       </div> 
      </div> 
      <script src="js/initOptions.js"></script> 
      <script src="js/main.js"></script> 
      <script src="js/messages.js"></script> 
     </body> 
</html> 

main.js:

function wlCommonInit(){ 
    $("#pagePort").load("page2.html"); 
} 

page2.html與index.html位於同一級別,僅包含<h1>Success</h1>

+0

thx它可以與新的乾淨項目 – user3293738 2014-10-07 07:53:14