Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12950 closed defect (invalid)

chained "dojo.connect"s' parameter and execution order

Reported by: yiqin yu Owned by:
Priority: high Milestone: tbd
Component: General Version: 1.6.0
Keywords: dojo.connect, excution order Cc:
Blocked By: Blocking:

Description

4 functions named a, b, c and d. They have relationships as follows: (1)when a is called, b is triggered; (2)when b is called, c is triggered; (3)when c is called, d is triggered.

Implemented by dojo.connect:

function a(){console.log("a")};
function b(){console.log("b")};
function c(){console.log("c")};
function d(){console.log("d")};
dojo.connect(null, "c", null, d);  //Connect c to d need to be put firstly
dojo.connect(null, "b", null, c);
dojo.connect(null, "a", null, b);
a();

Then the output in console will be: a b c d

But once I do not follow the above execution order of dojo.connect and change the sequence, certain function will not work:

dojo.connect(null, "a", null, b);
dojo.connect(null, "b", null, c);
dojo.connect(null, "c", null, d); 
a();

The output in console is: a b

In which c & d is not successfully called.

Alternatively, if we change the forth parameter of each dojo.connect to string:

dojo.connect(null, "a", null, "b");
dojo.connect(null, "b", null, "c"); 
dojo.connect(null, "c", null, "d"); 
a();

Then all functions are called successfully: a b c d

Attachments (1)

test2.html (586 bytes) - added by yiqin yu 9 years ago.

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by yiqin yu

Attachment: test2.html added

comment:1 Changed 9 years ago by Eugene Lazutkin

Resolution: invalid
Status: newclosed

That's exactly how it is supposed to work with stand-alone functions. The explanation "why" is relatively long. Short answer: use the workaround you discovered: names vs. direct function references.

comment:2 Changed 9 years ago by bill

I added a hopefully comprehensible explanation to http://docs.dojocampus.org/quickstart/events.

Note: See TracTickets for help on using tickets.