Is the Radio button disabled after a modal dialog appears?

I would like to show a modal dialogue if a person chooses "No." And it works, but I also need to leave the selected answer "No."

So, after I closed the modal window switch, you did not select. Any ideas how to fix this?

here is my code:

$(function() {
                $('#btnNext').attr('disabled', true);
                $('input[type="radio"]').change(function(e) {
                    var $yes = $('input[type="radio"][value="Yes"]');
                    var $no = $('input[type="radio"][value="No"]');
                    if ($yes.filter(':checked').length === $yes.length) {
                        $('#btnNext').attr('disabled', false);
                    } else {
                        $('#btnNext').attr('disabled', true);

                        var $nope = $(this).attr("name");
                        var $value = $(this).attr("value");
                     if ($value === "No") {
                       $(this).attr("checked", "checked"); // $(this).attr("checked", true);    
                            $('#' + $nope).dialog('open');
                     }
                    }
                });
        });
+3
source share
2 answers
$("#radioSelector").checked = false; 

But this is a duplicate: How do I uncheck a switch?

Update

Sorry, try the following:

$(function() {
    $('#btnNext').attr('disabled', true);
    $('input[type="radio"]').change(function(e) {
        if ( $(this).is(":checked") && $(this).val() == "No"){
            var $nope = $(this).attr("name");
            $('#' + $nope).dialog('open');
        }
    });
});
0
source

Opening the modals seems to prevent the completion of the default radio interference selection event. Try delaying the opening of the modal file until the radio event ends:

setTimeout(function() {
    $('#' + $nope).dialog('open');
}, 1);
0
source

All Articles