Opened 15 years ago

Closed 15 years ago

#3513 closed defect (fixed)

dojoAttachEvent problem within ContentPane

Reported by: guest Owned by: liucougar
Priority: high Milestone: 1.0
Component: Dijit Version: 0.9
Keywords: Cc:
Blocked By: Blocking:


0.9 nightly 24/06/07 I have a custom templated widget that uses a content pane within the template Something like this:


<div dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="20" id="pageViewer">
<button  dojoAttachEvent="onclick:addPage">Test</button>


dojo._hasResource["foo.Test"] = true;
	[dijit._Widget, dijit._Templated],
        addPage: function() {


When clicking on the button displayed nothing happens. However, if I remove the content pane widget clicking on the button brings up the alert box.

It's as if nested dojoAttachEvent attributes are not being processed.

The actual use case for this scenario is when a widget contains a dialog where the controls affect the containee widget.

Affects Firefox and IE 7.

Attachments (1)

_attachTemplateNodes.txt (3.0 KB) - added by guest 15 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 15 years ago by guest

I have a couple of suggestions although I appreciate that the behaviour that I am seeing could be by design, in which case please just close this bug:

In dijit._Templated._attachTemplateNodes:

  1. The call to this.connect(baseNode, tevt, thisFunc); should check to see if the target function exists on the baseNode. If it doesn't then it should attach to the baseNode.domNode as the node may be an html input of some sort.
    if(baseNode[tevt]) {
    this.connect(baseNode, tevt, thisFunc);
    else {
    this.connect(baseNode.domNode, tevt, thisFunc);

Even if the widget does not contain any widgets it still needs to process dojoAttachPoint and dojoAttachEvent attributes

  1. All nodes still need to be processed even if a widget is encountered.
    if(this.widgetsInTemplate && getAttrFunc(baseNode,'dojoType')){

currently short circuits the function if a widget is encountered, however that widget could be a container widget and will need its child nodes processed. Therefore the logic can be changed to:

if(!(this.widgetsInTemplate && getAttrFunc(baseNode,'dojoType'))){

    ---Rest of loop contents here---


I have attached the fully modified version of this method.

Changed 15 years ago by guest

Attachment: _attachTemplateNodes.txt added

comment:2 Changed 15 years ago by guest

Please ignore the following from the above change:

'Even if the widget does not contain any widgets it still needs to process dojoAttachPoint and dojoAttachEvent attributes'

comment:3 Changed 15 years ago by guest

I have done some further development and come up with the following for suggestion 1 above.

if(baseNode[tevt] || baseNode["domNode"] == null) {
//All widgets where the target method exists or all non widgets
this.connect(baseNode, tevt, thisFunc);
else {
//All widgets where target event does not exist
this.connect(baseNode.domNode, tevt, thisFunc);

comment:4 Changed 15 years ago by bill

Milestone: 1.0
Owner: changed from bill to liucougar

I don't think this is intended to be supported. Cougar, what do you think?

comment:5 Changed 15 years ago by guest

Looks like suggestion 2 has been fixed in the 0.9 beta. Suggestion 1 desn't really pertain to this bug, I'll open a separate enhancement ticket with full justification there.

comment:6 Changed 15 years ago by dante

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.