Forgot to make sure that oldData actually had data in it before the copy attempt.
[jquery.git] / test / delegatetest.html
1 <html>\r
2     <head>\r
3         <script src='../dist/jquery.js' type='text/javascript'></script>\r
4         <style>\r
5         .red {\r
6             background-color: red;\r
7             border: solid 3px red;\r
8         }\r
9         </style>\r
10     </head>\r
11     <body>\r
12         <h2>Change Tests</h2>\r
13         <table>\r
14             <tr>\r
15                 <td>\r
16                 Change each:\r
17                 </td>\r
18                 <td>\r
19                 <select class='select_test'>\r
20                     <option value='one'>change me 1</option>\r
21                     <option value='two'>change me 2</option>\r
22                     <option value='three'>change me 3</option>\r
23                 </select>\r
24                 </td>\r
25                 <td>\r
26                 <select class='mselect_test' multiple="multiple">\r
27                     <option value='one'>change me 1</option>\r
28                     <option value='two'>change me 2</option>\r
29                     <option value='three'>change me 3</option>\r
30                 </select>\r
31                 </td>\r
32                 <td>\r
33                 <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox1"/>\r
34                 <label for="checkbox1">Checkbox 1</label><br/>\r
35                 <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox2"/>\r
36                 <label for="checkbox2">Checkbox 2</label>\r
37                 <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox3" disabled="disabled"/>\r
38                 <label for="checkbox3">Checkbox 3</label>\r
39                 </td>\r
40                 </td>\r
41                 </td>\r
42                 <td>\r
43                 <input type="radio" class="radio_test" name="myradio" id="radio1"/>\r
44                 <label for="radio1">Radio1</label><br/>\r
45                 <input type="radio" class="radio_test" name="myradio" id="radio2"/>\r
46                 <label for="radio2">Radio2</label>\r
47                 <input type="radio" class="radio_test" name="myradio" id="radio3" disabled="disabled"/>\r
48                 <label for="radio3">Radio3</label>\r
49                 </td>\r
50                 <td>\r
51                 <input class='test' value='' id='input' size='10' />\r
52                 <input class='test' value='test' id='input2' size='10' readonly="readonly" />\r
53                 </td>\r
54                 <td>\r
55                 <textarea rows='2'></textarea>\r
56                 </td>\r
57                 <td>$(document).bind('change')</td>\r
58             </tr>\r
59             <tr>\r
60                 <td>Live:</td>\r
61                 <td id='select' class="red">SELECT</td>\r
62                 <td id='mselect' class="red">MULTI</td>\r
63                 <td id='checkbox' class="red">CHECKBOX</td>\r
64                 <td id='radio' class="red">RADIO</td>\r
65                 <td id='text' class="red">TEXT</td>\r
66                 <td id='textarea' class="red">TEXTAREA</td>\r
67                 <td id='boundChange' class="red">DOCUMENT</td>\r
68             </tr>\r
69             <tr>\r
70                 <td>Bind:</td>\r
71                 <td id='selectbind' class="red">SELECT</td>\r
72                 <td id='mselectbind' class="red">MULTI</td>\r
73                 <td id='checkboxbind' class="red">CHECKBOX</td>\r
74                 <td id='radiobind' class="red">RADIO</td>\r
75                 <td id='textbind' class="red">TEXT</td>\r
76                 <td id='textareabind' class="red">TEXTAREA</td>\r
77             </tr>\r
78             <tr>\r
79                 <td>Focusin:</td>\r
80                 <td id='selectfocus' class="red">SELECT</td>\r
81                 <td id='mselectfocus' class="red">MULTI</td>\r
82                 <td id='checkboxfocus' class="red">CHECKBOX</td>\r
83                 <td id='radiofocus' class="red">RADIO</td>\r
84                 <td id='textfocus' class="red">TEXT</td>\r
85                 <td id='textareafocus' class="red">TEXTAREA</td>\r
86             </tr>\r
87             <tr>\r
88                 <td>Focusout:</td>\r
89                 <td id='selectblur' class="red">SELECT</td>\r
90                 <td id='mselectblur' class="red">MULTI</td>\r
91                 <td id='checkboxblur' class="red">CHECKBOX</td>\r
92                 <td id='radioblur' class="red">RADIO</td>\r
93                 <td id='textblur' class="red">TEXT</td>\r
94                 <td id='textareablur' class="red">TEXTAREA</td>\r
95             </tr>\r
96         </table>\r
97         <h2>Submit Tests</h2>\r
98         <table>\r
99         <tr>\r
100             <td>\r
101                 Submit each:\r
102             </td>\r
103             <td>\r
104                 <form action="" id="text_submit">\r
105                 <input class='test' type='text' value='Key Return To Submit'/>\r
106                 </form>\r
107             </td>\r
108             <td>\r
109                 <form action="" id="password_submit">\r
110                 <input class='test' type='password' value=''/>\r
111                 </form>\r
112             </td>\r
113             <td>\r
114                 <form action="" id="submit_submit">\r
115                 <input type='submit' value="Click Me To Submit" />\r
116                 </form>\r
117             </td>\r
118             <td>$(document).bind('submit')</td>\r
119         </tr>\r
120         <tr>\r
121                 <td>Results:</td>\r
122                 <td id='textSubmit' class="red">TEXT</td>\r
123                 <td id='passwordSubmit' class="red">PASSWORD</td>\r
124                 <td id='submitSubmit' class="red">BUTTON</td>\r
125                 <td id='boundSubmit' class="red">DOCUMENT</td>\r
126         </tr>\r
127         </table>\r
128 \r
129         <ul id="log"></ul>\r
130 \r
131         <script type='text/javascript'>\r
132         jQuery.fn.addChangeTest = function( id, prevent ) {\r
133                 this.bind("focusin", function(){\r
134                         jQuery(id + "focus").blink();\r
135                 }).bind("focusout", function(){\r
136                         jQuery(id + "blur").blink();\r
137                 });\r
138 \r
139                 return this.bind("change", function(e){\r
140                         jQuery(id + "bind").blink();\r
141                 }).live("change", function(e){\r
142                         if ( prevent ) {\r
143                                 e.preventDefault();\r
144                         }\r
145 \r
146                         jQuery(id).blink();\r
147                 });\r
148         };\r
149 \r
150         jQuery.fn.addSubmitTest = function( id, prevent ) {\r
151                 return this.live("submit", function(e){\r
152                         if ( prevent ) {\r
153                                 e.preventDefault();\r
154                         }\r
155 \r
156                         jQuery(id).blink();\r
157                 });\r
158         };\r
159 \r
160         jQuery.fn.blink = function(){\r
161                 return this.css("backgroundColor","green").css("border","solid 3px green").delay(700).queue(function(next){\r
162                         jQuery(this).css("backgroundColor","");\r
163                         next();\r
164                 });\r
165         };\r
166         \r
167         $(".select_test").addChangeTest("#select");\r
168         $(".mselect_test").addChangeTest("#mselect");\r
169         $(".checkbox_test").addChangeTest("#checkbox");\r
170         $(".radio_test").addChangeTest("#radio");\r
171         $('textarea').addChangeTest("#textarea");\r
172         $('#input').addChangeTest("#text");\r
173         $(document).bind("change", function(){\r
174                 jQuery("#boundChange").blink();\r
175         });\r
176         \r
177         $("#text_submit").addSubmitTest("#textSubmit", true);\r
178         $("#password_submit").addSubmitTest("#passwordSubmit", true);\r
179         $("#submit_submit").addSubmitTest("#submitSubmit", true);\r
180         $(document).bind("submit", function(){\r
181                 jQuery("#boundSubmit").blink();\r
182         });\r
183         \r
184         </script>\r
185     </body>\r
186 </html>\r