Disabling all other list action buttons when one is clicked

Hi all,

First time poster long time reader!

I’ve scoured the community for the answer to this but drawn a blank so now posting …
My use case is I need ALL action buttons on a list to become disabled for all list items when any action button on the list is clicked.

I’ve been experimenting with the following code but I just can’t get there.

<script>
var theEvent = new Object() ;
window.addEventListener("update-record-success-select-icp-list", (e) => {
    // doesnt fire until after the server responds
    console.log("update-record-success-select-icp-list");
    theEvent = e.detail ;
    var whichButton = theEvent.response.data.fields['User Choice'] ;
    if (whichButton == "Perfect") {
        window.location.replace("/generating-10-suspects");
    } else {
        window.location.reload();
    }
});

document.addEventListener("update-record-select-icp-list", function() {
    // what is the event I need to listen for to catch the click of the action button?
    console.log("update-record-select-icp-list");
    // looking for the action buttons so we can disable the others when one gets clicked
    const buttons = document.querySelectorAll('button');
    console.log(buttons);
    buttons.forEach(btn => {
        console.log(btn);
        btn.addEventListener('click', event => {
            console.log("A button got clicked : " + event.target.id );
        });
    });
});
</script>

Has anyone else solved this problem? Does anyone know what the event listener is for catching the event on the client BEFORE the server responds? Also any assistance in finding the action buttons in the DOM would also be gratefully received …

1 Like

Hey Softr community - no replies yet wondering if anyone has seen this?

1 Like