locked
Double click firing on disabled radio button. RRS feed

  • Question

  • User-1549556126 posted

    Never thought this would be an issue, I have radio buttons appended in my HTML table as a column and I am disabling them to finalize the selection but after disabling them on double click they get checked/unchecked. 

     $.each(response.message, function (key, value) {
                                    var tr = $("<tr></tr>");
                                    var tbody = $("#tbody");
    
                                    var arr = value.split(";");
                                    $.each(arr, function (i, obj) {
                                        var temp = arr[i].trim().split("=")[1];
    
                                        td = $("<td></td>");
                                        td.append(temp);
                                        tr.append(td);
                                    })
                                    //DropDownlist for required adjustments
                                    tr.append("<td><select id='ddlReqdAdjustment' class='form-control'> \
                                                <option>Keep</option> \
                                                <option>Remove</option> \
                                                <option>Remove After</option> \
                                            </select> \
                                        </td>");
                                    //Textbox with Validation to allow only integers
                                    tr.append("<td><input type='number' class='form-control myText' disabled max='366' maxlength='3' \
                                                    onkeypress = 'return (event.charCode != 8 && event.charCode == 0 \
                                                                            || (event.charCode >= 48 && event.charCode <= 57)) \
                                        </td>");
                                    //tr.append("<td ><input type='checkbox' class='fakeRadio form-control' name='chk' /> \
                                    //            <input name='chk' type='hidden' value='false' /> \
                                    //           </td>");
                                    tr.append("<td> <input type='radio' class='fakeRadio form-control' id='myChk' value='0'/> \
                                                    <label for='chk'/>\
                                               </td>");
                                    tbody.append(tr);
                                });

    This is what I tried:

    $('#myChk').dblclick(function (e) {
           
            if(e.target.disabled==true)
            return;
            e.preventDefault();
            e.stopImmediatePropagation();
            e.stopPropagation();
            return false;
        });
    

    Still not working..! Is it kinda a bug in the asp?

    Thursday, June 20, 2019 7:04 PM

All replies

  • User1520731567 posted

    Hi vyasnikul,

    vyasnikul

    $('#myChk').dblclick(function (e) {
           
            if(e.target.disabled==true)
            return;
            e.preventDefault();
            e.stopImmediatePropagation();
            e.stopPropagation();
            return false;
        });

    You saw your code,You only judged that the control has been disabled,so you can't disabled them.

    I suggest you could add else clause and set true for disabled attribute,for example:

     $('#myChk').dblclick(function (e) {
    
                    if (e.target.disabled == true)
                        return;
                    else { 
    $('#myChk')[0].disabled = true
    } e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); return false; });

    when I double click,Like the picture

    Best Regards.

    Yuki Tao

    Friday, June 21, 2019 5:06 AM