Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Dialog: Set the type on buttons. Fixes #6128 - Dialog: Buttons are no…

…t type="button".
  • Loading branch information...
commit cd7f10d480c923d095af6cbd844cbbdb5bb3813e 1 parent a2ddfd5
@scottgonzalez scottgonzalez authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  ui/jquery.ui.dialog.js
View
2  ui/jquery.ui.dialog.js
@@ -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)
@jitter
jitter added a note

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')
....
@scottgonzalez Owner

Thanks, Fixed in d7670b9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
.unbind('click')
.click(function() {
props.click.apply(self.element[0], arguments);
Please sign in to comment.
Something went wrong with that request. Please try again.