Javascript事件监听器未执行

I am calling the preConditionPostCure function from a button. The function is definitely getting called. Here is the function:

function preConditionPostCure(condition_id) {
    child_open('<?php echo get_permalink(67)."?id=new&condition_redirect="; ?>' + condition_id,750,1017);
    popupWindow.getElementById('acf_form_submit_btn').onclick = function goBacktoCondition() {      
        closepopup();
        $.post('<?php echo home_url()."/wp-content/themes/backyard-cures/backyard_funcs.php" ?>', {userId: '<?php echo get_current_user_id(); ?>', condition_redirect: condition_id}, function(data) { postConditionPostCure(data.cure_id) },'json');   
    }
}

Here is the child_open function:

function child_open(url,height,width)
    { 
    if(popupWindow!=null && !popupWindow.closed) {
        popupWindow.focus();
    }
    else {
        popupWindow = window.open(url,'_blank','height='+height+',width='+width);
    }
}

Here is the closepopup function:

function closepopup(){
    if(false == popupWindow.closed){
        popupWindow.close ();
    }
}

I know the function is getting called because the popup window is opening with the correct url. However I am getting an error on the next line where I attempt to define an event listener for an element in the popupWindow. I am attempting to define the function goBacktoCondition such that it will execute when the element gets clicked. Needless to say, the goBacktoCondition function is not getting called when I click on the element. I know this because the popupWindow is not closing. Additionally, I am getting an error for the problematic line on the console saying that "undefined is not a function".

Thanks in advance.