Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
<webview>: An action has already been taken for this "dialog" event

I need to display a webpage in webview and have certain navigations happen. Since webview does not let confirm dialogs pass through, I want to listen to the dialog events in the webview and then pass my own custom dialog and have the user action be the one that's going to be taken.

Listening to the webview for the event is easy enough:

webview.addEventListener('dialog', this.onDialogOpen);

And then I open the dialog with the said method:

private onDialogOpen (e: any): void {
    this.dialogOn = true;
    this.dialogEvent = e;
}

Now what I want is the user to interact with my dialog and pass its action to this dialogEvent, as this:

<button onclick="onDialogAction()">OK</button>

And run the script:

public onDialogAction() {
       this.dialogEvent.dialog.ok();
}

But at this point I get the error in the title:

webview: An action has already been taken for this "dialog" event.

As I understand, for some reason, the DialogEvent gets 'outdated' once some time has passed. If I say 'this.dialogEvent.dialog.ok();' inside onDialogOpen it works. I can also call 'this.dialogEvent.dialog.ok();' from any other method if I call it from onDialogOpen. However if I say, setTimeout within that onDialogOpen, it stops working again.

What would be the cause of this and what would be the right way to get around this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The solution was simple for anyone coming to this question from a search:

Simply adding

this.dialogEvent.preventDefault();

to onDialogOpen() does the trick. The problem was the default action for any dialog event is to go with cancel, and that gets triggered for some reason when DOM is loaded. But any dialog event can be prevented from going to default with preventDefault() apparently.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda