Skip to content

Commit ccb741b

Browse files
committed
Dialog: Don't use .attr( props, true ).
(cherry picked from commit a8de99c)
1 parent 8f0daea commit ccb741b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ui/jquery.ui.dialog.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,18 @@ $.widget("ui.dialog", {
369369
}
370370
if ( hasButtons ) {
371371
$.each( buttons, function( name, props ) {
372+
var button, click;
372373
props = $.isFunction( props ) ?
373374
{ click: props, text: name } :
374375
props;
375-
var button = $( "<button type='button'></button>" )
376-
.attr( props, true )
377-
.unbind( "click" )
378-
.click(function() {
379-
props.click.apply( that.element[0], arguments );
380-
})
376+
// Default to a non-submitting button
377+
props = $.extend( { type: "button" }, props );
378+
// Change the context for the click callback to be the main element
379+
click = props.click;
380+
props.click = function() {
381+
click.apply( that.element[0], arguments );
382+
};
383+
button = $( "<button></button>", props )
381384
.appendTo( that.uiButtonSet );
382385
if ( $.fn.button ) {
383386
button.button();

0 commit comments

Comments
 (0)