|
26 | 26 | ok( elem.siblings( "label[for='chk\\[\\'3\\'\\]-1']" ).length === 1, "element has exactly one sibling of the form label[for='chk[\'3\']-1']" );
|
27 | 27 | });
|
28 | 28 |
|
29 |
| - test( "widget can be disabled and enabled", function(){ |
30 |
| - var input = $( "#checkbox-1" ), |
31 |
| - button = input.parent().find( ".ui-btn" ); |
32 |
| - |
33 |
| - input.checkboxradio( "disable" ); |
34 |
| - input.checkboxradio( "enable" ); |
35 |
| - ok( !input.prop("disabled"), "start input as enabled" ); |
36 |
| - ok( !input.parent().hasClass( "ui-state-disabled" ), "no disabled styles" ); |
37 |
| - ok( !input.prop("checked"), "not checked before click" ); |
| 29 | + function testEnableDisable( theInput, theMethod ) { |
| 30 | + var button = theInput.parent().find( ".ui-btn" ); |
| 31 | + |
| 32 | + theMethod( theInput, true ); |
| 33 | + theMethod( theInput, false ); |
| 34 | + ok( !theInput.prop("disabled"), "start input as enabled" ); |
| 35 | + ok( !theInput.parent().hasClass( "ui-state-disabled" ), "no disabled styles" ); |
| 36 | + ok( !theInput.prop("checked"), "not checked before click" ); |
38 | 37 | button.trigger( "click" );
|
39 |
| - ok( input.prop("checked"), "checked after click" ); |
| 38 | + ok( theInput.prop("checked"), "checked after click" ); |
40 | 39 | ok( button.hasClass( "ui-checkbox-on" ), "active styles after click" );
|
41 | 40 | button.trigger( "click" );
|
42 |
| - input.checkboxradio( "disable" ); |
43 |
| - ok( input.prop( "disabled" ), "input disabled" ); |
44 |
| - ok( input.parent().hasClass( "ui-state-disabled" ), "disabled styles" ); |
45 |
| - ok( !input.prop( "checked" ), "not checked before click" ); |
| 41 | + theMethod( theInput, true ); |
| 42 | + ok( theInput.prop( "disabled" ), "input disabled" ); |
| 43 | + ok( theInput.parent().hasClass( "ui-state-disabled" ), "disabled styles" ); |
| 44 | + ok( !theInput.prop( "checked" ), "not checked before click" ); |
46 | 45 | button.trigger( "click" );
|
47 |
| - ok( !input.prop( "checked" ), "not checked after click" ); |
| 46 | + ok( !theInput.prop( "checked" ), "not checked after click" ); |
48 | 47 | ok( !button.hasClass( "ui-checkbox-on" ), "no active styles after click" );
|
| 48 | + } |
| 49 | + |
| 50 | + test( "widget can be disabled and enabled via enable()/disable() method", function(){ |
| 51 | + testEnableDisable( $( "#checkbox-disabled-test-1" ), function( theInput, isDisabled ) { |
| 52 | + theInput.checkboxradio( isDisabled ? "disable" : "enable" ); |
| 53 | + }); |
| 54 | + }); |
| 55 | + |
| 56 | + test( "widget can be disabled and enabled via option 'disabled'", function(){ |
| 57 | + testEnableDisable( $( "#checkbox-disabled-test-2" ), function( theInput, isDisabled ) { |
| 58 | + theInput.checkboxradio( "option", "disabled", isDisabled ); |
| 59 | + }); |
| 60 | + }); |
| 61 | + |
| 62 | + test( "widget can be disabled and enabled via prop + refresh()", function(){ |
| 63 | + testEnableDisable( $( "#checkbox-disabled-test-3" ), function( theInput, isDisabled ) { |
| 64 | + theInput.prop( "disabled", isDisabled ).checkboxradio( "refresh" ); |
| 65 | + }); |
49 | 66 | });
|
50 | 67 |
|
51 | 68 | test( "clicking a checkbox within a controlgroup does not affect checkboxes with the same name in the same controlgroup", function(){
|
|
0 commit comments