dojo.connect won't connect 'onclick' with button

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2010-06-09T17:49:53Z Indexed on 2010/06/09 17:52 UTC
Read the original article Hit count: 242

Filed under:
|
|
|

I'm running into a problem using dojo.connect() to connect an 'onclick' event with this button:

<button dojoType="dijit.form.Button" widgetId="inbox_button" id="inbox_button">Inbox</button>

and the code making the connection is:

var inbox_button=dojo.byId("inbox_button");
dojo.connect(inbox_button,'onclick',function(){
    var container=dijit.byId("center");
    container.addChild(new dijit.layout.ContentPane({region: "left", content: "...", style: "width: 100px;"}))
});

However, instead of executing the function when the button is clicked, ANY onclick event triggers the function, and I end up with a lot of children containers.

Even though I'm pretty certain the .connect() function should be available as part of dojo's base functionality, I've 'required' it explicitly:

dojo.require("dojo._base.connect");

Any ideas as to why this might be happening?

© Stack Overflow or respective owner

Related posts about button

Related posts about dojo