1 | <html> |
---|
2 | <head> |
---|
3 | <script src="http://code.jquery.com/jquery-1.4.2.js" type="text/javascript"></script> |
---|
4 | <script type="text/javascript"> |
---|
5 | var test = {}; |
---|
6 | |
---|
7 | |
---|
8 | function testOne() |
---|
9 | { |
---|
10 | $(test).trigger('onetest'); |
---|
11 | } |
---|
12 | |
---|
13 | function testBind() |
---|
14 | { |
---|
15 | $(test).trigger('bindtest'); |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | $( |
---|
20 | function() { |
---|
21 | $(test).one("onetest", one_Handler); |
---|
22 | $(test).bind("bindtest", bind_Handler); |
---|
23 | } |
---|
24 | ); |
---|
25 | |
---|
26 | |
---|
27 | function one_Handler() |
---|
28 | { |
---|
29 | alert("one call"); |
---|
30 | } |
---|
31 | |
---|
32 | function bind_Handler() |
---|
33 | { |
---|
34 | alert("bind call"); |
---|
35 | } |
---|
36 | </script> |
---|
37 | </head> |
---|
38 | <body> |
---|
39 | <button onclick="javascript:testOne();">TEST with One</button> |
---|
40 | <button onclick="javascript:testBind();">TEST with Bind</button> |
---|
41 | </body> |
---|
42 | </html> |
---|