dojo 第二个选项卡容器事件- onFocus

kq0g1dla  于 2022-12-16  发布在  Dojo
关注(0)|答案(3)|浏览(165)

我有一个标签容器,我想执行一些js当我点击标签的标题栏。
我好像不知道怎么给它加个活动。
编辑:
看起来我将使用onFocus,但是我仍然在寻找正确的语法方面遇到了困难。
编辑:找到了onFocus and onBlur,但仍然很难让它工作。

kq4fsx7k

kq4fsx7k1#

您需要连接到_transition事件。

var tabs = dijit.byId("tabs");
dojo.connect(tabs,"_transition", function(newPage, oldPage){
    console.log("I was showing: ", oldPage || "nothing");
    console.log("I am now showing: ", newPage);
});

其中“tabs”是您的标签容器。

bxfogqkk

bxfogqkk2#

下面是一个在Dojo 1.8中工作的完整代码示例,我已经测试过它:

require(["dijit/registry",  "dojo/on", "dojo/ready", "dojo/domReady!"], function (registry, on, ready) {
    ready(function () { //wait till dom is parsed into dijits
        var panel = registry.byId('mainTab');   //get dijit from its source dom element
        on(panel, "Click", function (event) {   //for some reason onClick event doesn't work 
            alert(panel.selectedChildWidget.id);  
        });
    });
});
s1ag04yj

s1ag04yj3#

正确的Dojo 1.7+应该是;

var tabs = registry.byId('someTabs');
tabs.watch("selectedChildWidget", function(name, oval, nval){
    console.log("selected child changed from ", oval, " to ", nval);
});

另一种方式可以是

var tabs = registry.byId('someTabs');
aspect.after(tabs, "selectChild", function (event) {
     console.log("You selected ", tabs.selectedChildWidget.id);
});

相关问题