Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
<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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda