Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 67 lines (42 sloc) 1.788 kb
fcc4fff @phiggins42 monster commit from moinconverter, which is always done prior to the svn...
phiggins42 authored
1 .. _dojo/connect:
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
2
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
3 ==============
4 dojo.connect()
5 ==============
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
6
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
7 Deprecated.
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
8
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
9 Dojo versions prior to 1.7 used dojo.connect() for event handling and advice.
10 But it's functionality has been replaced by :ref:`dojo/on module <dojo/on>` and the :ref:`dojo/aspect module's after() method <dojo/aspect#after>`.
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
11
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
12 Events
13 ------
14 As of Dojo 1.7, the preferred way of handling events is to use the new lightweight :ref:`dojo/on <dojo/on>` module.
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
15
16
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
17 For compatibility reasons, the dojo.connect api's will remain fully supported through remaining 1.x releases, but will likely be removed in Dojo 2.0. Migration from connect() to on() should be straightforward as the api signature is very similar.
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
18
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
19 Old code like:
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
20
c49c87d @phiggins42 normalization
phiggins42 authored
21 .. js ::
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
22
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
23 var handle = dojo.connect(node, "onclick", callback);
24 ...
25 dojo.disconnect(handle);
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
26
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
27 should be converted to:
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
28
c49c87d @phiggins42 normalization
phiggins42 authored
29 .. js ::
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
30
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
31 require(["dojo/on"], function(on){
32 var handle = on(node, "click", callback);
9dd52dc @phiggins42 mondo whitespace change
phiggins42 authored
33 ...
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
34 handle.remove();
9dd52dc @phiggins42 mondo whitespace change
phiggins42 authored
35 });
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
36
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
37 Note that:
38 - the "on" prefix was dropped, and "onclick" became "click"
39 - the "handle" has a remove() method, rather than there being a function like dojo.disconnect()
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
40
41
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
42 Advice
43 ------
44 The preferred way of handling after advice is to use the new lightweight :ref:`dojo/aspect's after() method <dojo/aspect#after>`.
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
45
46
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
47 Old code:
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
48
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
49 .. js ::
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
50
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
51 var handle = dojo.connect(myInstance, "execute", callback);
52 ...
53 dojo.disconnect(handle);
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
54
55
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
56 is changed to
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
57
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
58 .. js ::
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
59
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
60 require(["dojo/aspect"], function(aspect){
61 aspect.after(myInstance, "execute", callback);
62 ...
63 handle.remove();
64 });
d608cc5 @phiggins42 \r\n -> \n conversion.
phiggins42 authored
65
2db6e6b @wkeese Overhaul event documentation.
wkeese authored
66 Note that callback() should not return a value, because if it did the returned value would be reported as the value that myInstance.execute() appeared to return, which is not what dojo.connect() did.
Something went wrong with that request. Please try again.