Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
El cuadro de diálogo de confirmación de Primeng se muestra cuando no debería

Tengo un método que verifica si alguna propiedad del objeto en la matriz es igual a 'no listo'. Si es así, debe informar al usuario sobre eso y preguntarle si aún desea continuar. Si no, hay un retorno que rompe el método y si es así, el método continúa y hay un cuadro de diálogo de confirmación más

 createOrder() { if(this.orders.filter(e => e.statusName === 'not ready').length > 0){ this.confirmationService.confirm({ message: 'There is already ongoing order. Do you want start another?', header: 'Order', icon: 'fa fa-exclamation-triangle', acceptLabel: 'Yes', rejectLabel: 'No', key: 'ongoin', accept: () => { }, reject: () => { return } }) } this.confirmationService.confirm({ message: 'Are you sure?', header: 'Order', icon: 'fa fa-exclamation-triangle', acceptLabel: 'Yes', rejectLabel: 'No', key: 'confirm', accept: () => { *//add object code* } });

Así se ve en html:

 <button pButton tooltipPosition="left" (click)="createOrder()" icon="fa fa-plus-square" class="ui-button-warning"> </button> <p-confirmDialog key='ongoin'></p-confirmDialog> <p-confirmDialog key='confirm'></p-confirmDialog>

Mi problema es que ambos diálogos de confirmación aparecen al mismo tiempo. Supongo que es por usar dos veces en html. Pero si cambio eso a

 <p-confirmDialog></p-confirmDialog>

Solo funciona el primero ('Ya está en curso...') y el segundo ('¿Estás seguro') después de hacer clic en Sí no aparece. ¿Cómo hago para que funcione?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debería estar llamando al segundo cuadro de diálogo después de que ocurra la confirmación. Lo que sucede al accept o reject devoluciones de llamada. Pero está llamando inmediatamente a this.confirmationService.confirm nuevamente y está causando que se muestren ambos cuadros de diálogo.

Deberías tener algo como lo siguiente:

 createOrder() { if(this.orders.filter(e => e.statusName === 'not ready').length > 0){ this.confirmationService.confirm({ message: 'There is already ongoing order. Do you want start another?', header: 'Order', icon: 'fa fa-exclamation-triangle', acceptLabel: 'Yes', rejectLabel: 'No', key: 'ongoin', accept: () => { // do something here this.showAnotherDialog(); }, reject: () => { // if you want to show another dialog on reject you should call it here return } }) } else { this.showAnotherDialog(); } } showAnotherDialog() { this.confirmationService.confirm({ message: 'Are you sure?', header: 'Order', icon: 'fa fa-exclamation-triangle', acceptLabel: 'Yes', rejectLabel: 'No', key: 'confirm', accept: () => { *//add object code* } }); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!