Skip to content

Commit

Permalink
Dialog: Set the type on buttons. Fixes #6128 - Dialog: Buttons are no…
Browse files Browse the repository at this point in the history
…t type="button".
  • Loading branch information
scottgonzalez committed Sep 30, 2010
1 parent a2ddfd5 commit cd7f10d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ui/jquery.ui.dialog.js
Expand Up @@ -376,7 +376,7 @@ $.widget("ui.dialog", {
props = $.isFunction( props ) ?
{ click: props, text: name } :
props;
var button = $('<button></button>', props)
var button = $('<button type="button"></button>', props)

This comment has been minimized.

Copy link
@jitter

jitter Sep 30, 2010

This will trigger this error in all browsers doc.createDocumentFragment is not a function

as jQuery( html, props ) isn't built to be used in this way (jQuery( html, props )). The docs describe the html parameter as

html A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).

Passing in as html anything other (complex html, not single standalone tag e.g as above with "inline" attributes) while the second parameter (as in this case) isn't a context but a map of attributes will trigger the above exception.

As simply doing { click: props, text: name, type: "button" } and $('<button></button>', props) won't work, due to IE not allowing to change the type after the button has been created, I propose this alternative fix

var button = $('<button type="button"></button>')
             .attr(props, true)
             .unbind('click')
....

This comment has been minimized.

Copy link
@scottgonzalez

scottgonzalez Oct 1, 2010

Author Member

Thanks, Fixed in d7670b9.

.unbind('click')
.click(function() {
props.click.apply(self.element[0], arguments);
Expand Down

0 comments on commit cd7f10d

Please sign in to comment.