@@ -186,8 +186,40 @@ test("close", function() {
186
186
el . remove ( ) ;
187
187
} ) ;
188
188
189
+ //handling of deprecated beforeclose (vs beforeClose) option
190
+ //Ticket #4669 http://dev.jqueryui.com/ticket/4669
191
+ //TODO: remove in 1.9pre
192
+ test ( "beforeclose" , function ( ) {
193
+ expect ( 10 ) ;
194
+
195
+ el = $ ( '<div></div>' ) . dialog ( {
196
+ beforeclose : function ( ev , ui ) {
197
+ ok ( true , '.dialog("close") fires beforeClose callback' ) ;
198
+ equals ( this , el [ 0 ] , "context of callback" ) ;
199
+ equals ( ev . type , 'dialogbeforeclose' , 'event type in callback' ) ;
200
+ same ( ui , { } , 'ui hash in callback' ) ;
201
+ return false ;
202
+ }
203
+ } ) ;
204
+ el . dialog ( 'close' ) ;
205
+ isOpen ( 'beforeclose (deprecated) callback should prevent dialog from closing' ) ;
206
+ el . remove ( ) ;
207
+
208
+ el = $ ( '<div></div>' ) . dialog ( ) ;
209
+ el . dialog ( 'option' , 'beforeclose' , function ( ev , ui ) {
210
+ ok ( true , '.dialog("close") fires beforeClose callback' ) ;
211
+ equals ( this , el [ 0 ] , "context of callback" ) ;
212
+ equals ( ev . type , 'dialogbeforeclose' , 'event type in callback' ) ;
213
+ same ( ui , { } , 'ui hash in callback' ) ;
214
+ return false ;
215
+ } ) ;
216
+ el . dialog ( 'close' ) ;
217
+ isOpen ( 'beforeclose (deprecated) callback should prevent dialog from closing' ) ;
218
+ el . remove ( ) ;
219
+ } ) ;
220
+
189
221
test ( "beforeClose" , function ( ) {
190
- expect ( 9 ) ;
222
+ expect ( 14 ) ;
191
223
192
224
el = $ ( '<div></div>' ) . dialog ( {
193
225
beforeClose : function ( ev , ui ) {
@@ -202,6 +234,18 @@ test("beforeClose", function() {
202
234
isOpen ( 'beforeClose callback should prevent dialog from closing' ) ;
203
235
el . remove ( ) ;
204
236
237
+ el = $ ( '<div></div>' ) . dialog ( ) ;
238
+ el . dialog ( 'option' , 'beforeClose' , function ( ev , ui ) {
239
+ ok ( true , '.dialog("close") fires beforeClose callback' ) ;
240
+ equals ( this , el [ 0 ] , "context of callback" ) ;
241
+ equals ( ev . type , 'dialogbeforeclose' , 'event type in callback' ) ;
242
+ same ( ui , { } , 'ui hash in callback' ) ;
243
+ return false ;
244
+ } ) ;
245
+ el . dialog ( 'close' ) ;
246
+ isOpen ( 'beforeClose callback should prevent dialog from closing' ) ;
247
+ el . remove ( ) ;
248
+
205
249
el = $ ( '<div></div>' ) . dialog ( ) . bind ( 'dialogbeforeclose' , function ( ev , ui ) {
206
250
ok ( true , '.dialog("close") triggers dialogbeforeclose event' ) ;
207
251
equals ( this , el [ 0 ] , "context of event" ) ;
0 commit comments