ToolBarButton不触发事件

时间:2013-03-13 12:00:18

标签: ibm-mobilefirst

我有这个事件捕手:

    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项目并添加了标题和工具栏按钮,这里是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>

&#34; Page设计师&#34;显示标题和工具栏但是当我在Android模拟器上运行它时,我得到一个黑屏! 有什么想法吗?

1 个答案:

答案 0 :(得分:1)

也许是因为你使用JQuery语法绑定事件?

使用此Dojo代码,相同的标记对我来说很好:

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