]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Don't use .attr( props, true ).
authorScott González <scott.gonzalez@gmail.com>
Mon, 5 Nov 2012 14:37:01 +0000 (09:37 -0500)
committerScott González <scott.gonzalez@gmail.com>
Thu, 8 Nov 2012 22:53:35 +0000 (17:53 -0500)
(cherry picked from commit a8de99c791ae24e558920e1756fb7d0bf9dfc166)

ui/jquery.ui.dialog.js

index c1ac7bc9ef6a68ec0b0063a4aa0c58ad867120d5..a031eb5e0c29c103cb31075546be07e0d5ffb738 100644 (file)
@@ -369,15 +369,18 @@ $.widget("ui.dialog", {
                }
                if ( hasButtons ) {
                        $.each( buttons, function( name, props ) {
+                               var button, click;
                                props = $.isFunction( props ) ?
                                        { click: props, text: name } :
                                        props;
-                               var button = $( "<button type='button'></button>" )
-                                       .attr( props, true )
-                                       .unbind( "click" )
-                                       .click(function() {
-                                               props.click.apply( that.element[0], arguments );
-                                       })
+                               // Default to a non-submitting button
+                               props = $.extend( { type: "button" }, props );
+                               // Change the context for the click callback to be the main element
+                               click = props.click;
+                               props.click = function() {
+                                       click.apply( that.element[0], arguments );
+                               };
+                               button = $( "<button></button>", props )
                                        .appendTo( that.uiButtonSet );
                                if ( $.fn.button ) {
                                        button.button();