ThinkTeamwork
ThinkTeamwork

Reputation: 594

How to make radio :selected work in Safari

This works in Chrome but not in Safari:

require(['jquery'], function($)
{
    // store the value of the previous selected radio control 
    // before the current one gets selected
    $(document).on('focus', 'input[type=radio]', function () {
        // search all radio input fields with the same name within the same form
        // and store the value of active one into the oldValue property
        $(this).data('oldValue', $(this.form[this.name]).filter(':checked').val());
    });
});

Which part of the snippet is causing the trouble? I'm steppin' in the dark here...

Upvotes: 0

Views: 662

Answers (1)

Jai
Jai

Reputation: 74738

change this line:

$(this).data('oldValue', $(this.form[this.name]).filter(':checked').val());

to this:

$(this).data('oldValue', $(this).closest('form').find(':checked').val());

Other than this you can change focus event to change:

$(document).on('change', 'input[type=radio]', function () {

Upvotes: 1

Related Questions