#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)
Change History (3)
Changed 10 years ago by
Attachment: | test2.html added |
---|
comment:1 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 10 years ago by
I added a hopefully comprehensible explanation to http://docs.dojocampus.org/quickstart/events.
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.