Add support for radio buttons

Stripe’s saved card radio options for example.
This commit is contained in:
Caleb Burks 2017-01-24 21:11:39 -06:00
parent 273952085c
commit ded7914dba
1 changed files with 3 additions and 3 deletions

View File

@ -296,7 +296,7 @@ jQuery( function( $ ) {
var ID = $( this ).attr( 'id' );
if ( ID ) {
if ( 'checkbox' === $( this ).attr( 'type' ) ) {
if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) {
paymentDetails[ ID ] = $( this ).prop( 'checked' );
} else {
paymentDetails[ ID ] = $( this ).val();
@ -323,8 +323,8 @@ jQuery( function( $ ) {
var ID = $( this ).attr( 'id' );
if ( ID ) {
if ( 'checkbox' === $( this ).attr( 'type' ) && paymentDetails[ ID ] ) {
$( this ).prop( 'checked', true ).change();
if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) {
$( this ).prop( 'checked', paymentDetails[ ID ] ).change();
} else {
$( this ).val( paymentDetails[ ID ] ).change();
}