Button inside repeater throwing error when clicked

Hi there,
I’m trying to allow a user to post a reply to a comment. The reply button expands/collapses the reply form (this works as expected). The submit button should add the reply to an array in the comments collection, reset the input fields, and collapse the reply form.

Instead, when the user tries to submit, the console shows:

Uncaught (in promise) TypeError: x[e.inputType] is not a function.

Here is the relevant code:

$w.onReady(()=> {
    $w("#commentsList").onItemReady(($item,itemData,index)=> {
        setOnClick($item,itemData,index);
    });
 }
 
function setOnClick($item,itemData,index) {
    const replyButton = $item("#button3");
    const replyForm = $item("#box3");
    const submitReplyButton = $item("#text15");

    submitReplyButton.onClick((event) => {
        setReply($item,itemData,index);
        resetReplyForm($item,itemData,index);
        toggleReplyForm(replyForm);
        showReplies($item,itemData,index);
    });
}

function setReply ($item,itemData,index) {  
    const reply = {
            name: $item("#input2").value,
            text: $item("#textBox2").value
        }
 
    if(itemData.replies){
        itemData.replies.push(reply);
    }else{
        itemData.replies = [reply];
    }

    wixData.update("Comments", itemData);
}

I’ve tried using the same approach with $w.at() outside of the onItemReady but it leads to the same error.

Thanks for any help!

Where does the error occur? On the wixData.update()?

Are you populating the Repeater with a connected dataset ? Or are you setting the .data property with results from a query ?

Please understand that it is difficult to debug someone else’s code. You will need to simplify your code so that you can isolate where the problem is.