ibm-mobilefirst
2013-03-13 72 views 0 likes 
0

我有這樣的事件捕手:的ToolBarButton不觸發事件

WLJQ('button#refreshBte').bind('click', function() { 
     console.log("start refresh..."); 
    }); 

有人能解釋我爲什麼:

與作品:

<div data-dojo-type="dojox.mobile.Heading" 
     data-dojo-props='fixed:"top"'> 
     Header 
    </div> 
    <button id="refreshBte" data-dojo-type="dojox.mobile.Button" 
      style="float: right">Refresh</button> 

,不與工作:

<div data-dojo-type="dojox.mobile.Heading" 
     data-dojo-props='fixed:"top"'> 
     Header 
     <button id="refreshBte" data-dojo-type="dojox.mobile.ToolBarButton" 
      style="float: right">Refresh</button> 
    </div> 

它不是如果我用一個按鈕替換ToolBarButton。

THX


編輯: 因爲它不是爲我工作,我創建一個簡單的WL項目,並添加標題和的ToolBarButton,這裏的HTML:

<!DOCTYPE HTML> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>Test</title> 
<meta name="viewport" 
    content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
<meta name="apple-mobile-web-app-capable" content="yes"> 
<link rel="shortcut icon" href="images/favicon.png"> 
<link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
<link rel="stylesheet" href="css/Test.css"> 
<script> 
    window.$ = window.jQuery = WLJQ; 
</script> 
<script type="text/javascript" 
    data-dojo-config="isDebug: false, async: true, parseOnLoad: true, mblHideAddressBar: false" 
    src="dojo/dojo.js"></script> 
</head> 
<body id="content" style="display: none;"> 
    <div data-dojo-type="dojox.mobile.ScrollableView" id="view0" 
     data-dojo-props="selected:true"> 
    <div data-dojo-type="dojox.mobile.Heading" 
     data-dojo-props="label:'Heading'"> 
      <button data-dojo-type="dojox.mobile.ToolBarButton" id="refreshBte">Label</button> 
     </div> 

    </div> 
    <!--application UI goes here--> 
    <script src="js/initOptions.js"></script> 
    <script src="js/Test.js"></script> 
    <script src="js/messages.js"></script> 
</body> 
</html> 

「頁面設計師「顯示標題和工具欄,但是當我在Android模擬器上運行它時,我得到了一個黑屏! 有什麼想法?

回答

1

也許是因爲你使用JQuery語法來綁定事件?我使用這個Dojo代碼

相同的標記工作正常:

require([ 
    "dojo/ready", 
    "dijit/registry" 
], function(ready, registry){ 
    ready(function(){ 
     registry.byId("refreshBte").on("click", function(){ 
      console.log("start refresh..."); 
     }); 
    }); 
}); 
+0

我會嘗試,但同時你覺得我的jQuery是正確的嗎? – ITDoVe 2013-03-15 12:35:17

+0

我試過了,但是我無法在Android上顯示widget,因此我爲測試創建了一個簡單的WL項目(請參閱上面的html),但在Android上出現了黑屏。不知道爲什麼? 這會幫助我進一步調查。 Thx – ITDoVe 2013-03-29 16:17:24

相關問題