Login Register

Attaching functions to TitlePane

I try to attach some functions to dijit.TitlePane, specifically to the events onClick and onMouseover.
Due to the nature of the projects, I have to do this declarative.

Tried two ways

<div dojoType="dijit.TitlePane" id="myId" title="myTitle">
My senseless text
    <script type="text/javascript">
      function myFunction() {
           alert('pane clicked');
       }
       dojo.connect(dijit.byId('myId'),"onClick",myFunction);
     </script>
</div>

and

<div dojoType="dijit.TitlePane" id="myId" title="myTitle" dojoAttachEvent="onClick: alert('Test')">
 My senseless Text
 </div>

Both doesnt work. As the panes are displayed correctly, I assumed there is no error in the includes and the dojo.require statements.

Where is my mistake?

try...

<div dojoType="dijit.TitlePane" id="myId" title="myTitle">
My senseless text
    <script type="dojo/method" event="onClick">
           alert('pane clicked');
    </script>
</div>

or

<div dojoType="dijit.TitlePane" id="myId" title="myTitle" onClick="alert('Test')">
 My senseless Text
 </div>

attachEvent is for templates....

-Karl

Tried both...

but both do not work.

on IRC trutwijd suggested dojo.AddOnLoad(dojo.connect(dijit.byId([...]))) which fired on load.

Strange enough.