Button: properly escape button names. Fixes #7505 - Button: Buttonset not applied to radio group with quotation/apostrophe in name.

This commit is contained in:
Mike Sherov 2012-11-19 08:37:41 -05:00
parent 4334b5d4f1
commit cc7df712cc
3 changed files with 17 additions and 1 deletions

View File

@ -59,6 +59,13 @@
<input type="radio" id="radio23" name="radio" checked="checked"><label for="radio23">Choice 3</label> <input type="radio" id="radio23" name="radio" checked="checked"><label for="radio23">Choice 3</label>
</div> </div>
</form> </form>
<form>
<div id="radio3">
<input type="radio" id="radio31" name="data['Page']['parse']" /><label for="radio31">Choice 1</label>
<input type="radio" id="radio32" name="data['Page']['parse']" checked="checked" /><label for="radio32">Choice 2</label>
<input type="radio" id="radio33" name="data['Page']['parse']" /><label for="radio33">Choice 3</label>
</div>
</form>
<input type="checkbox" id="check"><label for="check">Toggle</label> <input type="checkbox" id="check"><label for="check">Toggle</label>

View File

@ -1,8 +1,16 @@
/* /*
* button_events.js * button_events.js
*/ */
(function() { (function($) {
module("button: events"); module("button: events");
test("buttonset works with single-quote named elements (#7505)", function() {
expect( 1 );
$("#radio3").buttonset();
$("#radio33").click( function(){
ok( true, "button clicks work with single-quote named elements" );
}).click();
});
})(jQuery); })(jQuery);

View File

@ -29,6 +29,7 @@ var lastActive, startXPos, startYPos, clickDragged,
form = radio.form, form = radio.form,
radios = $( [] ); radios = $( [] );
if ( name ) { if ( name ) {
name = name.replace( /'/g, "\\'" );
if ( form ) { if ( form ) {
radios = $( form ).find( "[name='" + name + "']" ); radios = $( form ).find( "[name='" + name + "']" );
} else { } else {