aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-10-27 14:35:27 -0400
committerScott González <scott.gonzalez@gmail.com>2015-10-29 11:19:13 -0400
commite77fbe5388abeeb1d0f8f377161a0fc039897594 (patch)
tree78df261bb106e143f954588319d1fa4d828dc6dc /ui
parent5157c2520b0121019a4003110c342ef1a5dcba74 (diff)
downloadjquery-ui-e77fbe5388abeeb1d0f8f377161a0fc039897594.tar.gz
jquery-ui-e77fbe5388abeeb1d0f8f377161a0fc039897594.zip
Checkboxradio: Properly find radio groups from the associated form
Fixes #9973 Closes gh-1631
Diffstat (limited to 'ui')
-rw-r--r--ui/widgets/checkboxradio.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/ui/widgets/checkboxradio.js b/ui/widgets/checkboxradio.js
index b4f4de49d..107749201 100644
--- a/ui/widgets/checkboxradio.js
+++ b/ui/widgets/checkboxradio.js
@@ -93,9 +93,6 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
this._bindFormResetHandler();
- // this.form is set by the form-reset-mixin
- this.formParent = this.form.length ? this.form : $( "body" );
-
if ( this.options.disabled == null ) {
this.options.disabled = this.element[ 0 ].disabled;
}
@@ -151,17 +148,25 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
},
_getRadioGroup: function() {
+ var group;
var name = this.element[ 0 ].name;
- var formParent = this.formParent[ 0 ];
+ var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
if ( !name ) {
return $( [] );
}
- return this.formParent.find( "[name='" + $.ui.escapeSelector( name ) + "']" ).filter( function() {
- var form = $( this ).form();
- return ( form.length ? form : $( "body" ) )[ 0 ] === formParent;
- } ).not( this.element );
+ if ( this.form.length ) {
+ group = $( this.form[ 0 ].elements ).filter( nameSelector );
+ } else {
+
+ // Not inside a form, check all inputs that also are not inside a form
+ group = $( nameSelector ).filter( function() {
+ return $( this ).form().length === 0;
+ } );
+ }
+
+ return group.not( this.element );
},
_toggleClasses: function() {