开发者

Dojo & StackController/StackContainer

开发者 https://www.devze.com 2023-02-13 16:35 出处:网络
I\'m using StackContainer as a menu but I\'m having a problem to attach custom onclick events on \"tabs\" in stackcontainer.

I'm using StackContainer as a menu but I'm having a problem to attach custom onclick events on "tabs" in stackcontainer.

My app is basically laid out like this:

header
subheader
content

Header has the stackcontroller tabs and content obviously shows the content. However when I cli开发者_C百科ck any of the tab elements in the header, I want to run a function that changes subheader accordingly. Now how I can do this? Content switching works great so no problems there.

I'm using ContentPanes as tab elements and I tried to put onclick straight on them and I tried with dojo.connect - no luck. I have experience with jQuery & plain JS but I'm a dojo newbie so excuse me if I'm missing something really obvious :)


The easiest way to do this will be to use the pub/sub mechanism built into the widget.

On child selection the StackContainer will publish:

dojo.publish(this.id+"-selectChild", [page]);

where page is the child widget being selected.

So you should use:

dojo.subscribe(myStackId, function(/* dijit */ selectedChild) {
    // use the selectedChild to do what you want
});

As an aside, dijits provide normalised events which are camel cased. So you could connect to the onclick event of the dijit, but to do this you should use 'onClick'. However, you wouldn't necessarily guarantee that a child had been selected if you used this approach.

See http://dojotoolkit.org/reference-guide/dojo/publish.html

0

精彩评论

暂无评论...
验证码 换一张
取 消