Wednesday 27 October 2021

How to force disable the modal or a button?

When my users are readOnly, I want to limit some access. In this case, the ability to edit notes. I can't explain why with this code, I still can open up my note when the user is readOnly

if(codeParam == '' ) {

    //I am in side this code 
    $("a.btn, .btn-link, #logNote, pre, .btn").click(function() {
        return false; 
    });
}

https://mybabies.app/baby/797b808a-e8c6-4a83-acf4-14ebe1f776b1?code=rithys4k

Please click on the note box, you will see that somehow it still be able to trigger.

enter image description here

I even tried added the check and return false in showModal()

function showModal(val, type, logId ) {

    console.log("val, type, logId",val, type, logId);


    if(codeParam == '' ) {
       return false; 
    }

    ...

or tried preventDefault

if(codeParam == '' ) {
    $("a.btn, .btn-link, #logNote, pre, .btn").click(function(e) {
        e.preventDefault(); 
        return false; 
    });
}

If you spotted what I missed, please let me know.



from How to force disable the modal or a button?

No comments:

Post a Comment