Function when clicking on an alert

Good afternoon, I have an alert that appears when a button is clicked, this button calls a function, but this function is executed when the alert appears. I need this function to run only after the user clicks ok.

$$('#envia1').on('click', function () {
var sel = $("input[name='pergunta01']:checked").val();
if (sel == null) {

    app.dialog.alert('Você deve selecionar uma das respostas!', 'Resposta Invalida');
}
else if (sel == 'a') {      

    app.dialog.alert('Clique em OK para continuar!', 'Resposta Correta', nextQuestion());
}
else {
    app.dialog.alert('A alternativa correta era a opção A!', 'Resposta Errada', nextQuestion());
}
});
app.dialog.alert('Clique em OK para continuar!', 'Resposta Correta', function () {
  nextQuestion()
});
1 Like

Thank you, this worked.