Login Register

Invoking a JS function onclick of the TitlePane

Hi All,

I have implemented a dojo TitlePane div in my screen. I want to invoke a Java script function on click of the TitlePane.

Currently i have the below code, but the JS function 'test' is NOT called after i click the Titlepane.
------------------------------Code Snippet------------------------------

function test(){
alert('Test');
}

<body>
<div id="regionDiv" dojotype="TitlePane" label="TestPane" labelarrow="up" style="height:34px;" labelnodeclass="labelTitlePane" containernodeclass="contentTitlePane" open="false" onclick="test()">

some code

</div>
</body>

------------------------------Code Snippet------------------------------

Is it the correct way to inoke a Java script function onclick of the titlepane???

Please provide some tips.

It's not called because

It's not called because you'll never get a TitlePane created from that code. The dojotype should be "dijit.TitlePane" rather than just "TitlePane". I'm not sure what labelnodeclass, containernodeclass, and labelarrow are doing in there either. Oh, and the title of a TitlePane is defined by "title" not "label".

Assuming that you have a dojo.require("dijit.TitlePane") -- and all the necessary dojo setup -- the following logs "clicked!" on every click:

<div id="regionDiv"
     dojotype="dijit.TitlePane"
     title="Test Pane"
     style="height:34px;"
     open="false"
     onclick="console.log('clicked!')">

 some text
</div>

Thanks, I will try it out

Thanks for the reply.

Since i have an older version of dojo, giving 'dojoType=Titlepane' worked for me.

I will upgrade my dojo version and i will try out the above option.

I will get back to you about the status.

Regards,
Thani