]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: On form reset only call refresh on current button widgets. Fixed #9213: Butto...
authorTJ VanToll <tj.vantoll@gmail.com>
Sun, 7 Apr 2013 16:57:15 +0000 (12:57 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 17 Apr 2013 19:29:12 +0000 (15:29 -0400)
(cherry picked from commit 2de31fdbf498a6c20d196a96d007ea0f069644c5)

tests/unit/button/button_core.js
ui/jquery.ui.button.js

index dbc079818393c3935de1d7c00b84757e6f6bdcb4..16c7ca450c8c4f852b4204d1cd2b3cd70ab21e97 100644 (file)
@@ -153,6 +153,30 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
        ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
 });
 
+asyncTest( "Resetting a button's form should refresh the visual state of the button widget to match.", function() {
+       expect( 2 );
+       var form = $( "<form>" +
+               "<button></button>" +
+               "<label for='c1'></label><input id='c1' type='checkbox' checked>" +
+               "</form>" ),
+               button = form.find( "button" ).button(),
+               checkbox = form.find( "input[type=checkbox]" ).button();
+
+       checkbox.prop( "checked", false ).button( "refresh" );
+       ok( !checkbox.button( "widget" ).hasClass( "ui-state-active" ) );
+
+       form.get( 0 ).reset();
+       
+       // #9213: If a button has been removed, refresh should not be called on it when
+       // its corresponding form is reset.
+       button.remove();
+
+       setTimeout(function() {
+               ok( checkbox.button( "widget" ).hasClass( "ui-state-active" ));
+               start();
+       });
+});
+
 asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
        expect( 2 );
        var check = $( "#check" ).button(),
index fcb7b14d18799751a3052256b0e5aa136911d4a3..e0e166a7b06c5c44a96a99921053e95f1644ba53 100644 (file)
@@ -19,9 +19,9 @@ var lastActive, startXPos, startYPos, clickDragged,
        stateClasses = "ui-state-hover ui-state-active ",
        typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
        formResetHandler = function() {
-               var buttons = $( this ).find( ":ui-button" );
+               var form = $( this );
                setTimeout(function() {
-                       buttons.button( "refresh" );
+                       form.find( ":ui-button" ).button( "refresh" );
                }, 1 );
        },
        radioGroup = function( radio ) {