closing noty error popup when next error occures

188 Views Asked by At

yI would like noty to close "older" noty popups, which are still on the screen.

Version 2.3.7 (can't update to 3.2 or 4.x, but that is another problem)

Played with any combination of killer, maxVisible, force and dismissQueue but without result.

function notyErrorMsg(errorMsg) {
         console.log("notyErrorMsg(): "+errorMsg);
         n = noty({text: errorMsg, 
                       buttons: [
                                 { addClass:   'btn btn-danger',
                                       text:   'Close', 
                                    onClick:   function($noty) {
                                                  $noty.close();
                                               }
                                 }
                                ],
                       layout:       "center",         
                         type:       "error",
                        theme:       "defaultTheme",
                      timeout:       30000,
                       killer:       false,
                   maxVisible:       1,
                        force:       true,
                 dismissQueue:       true
                      }
         );
         logError(errorMsg);
      }

old noty popups should be closed but they are still open and have to be closed by user.

1

There are 1 best solutions below

0
Ali Zareshahi On BEST ANSWER

by attention to Noty Api Document you should close noty by use n.close() or $.noty.close(n.id) in your use case try to close by this.close() or use close function outside of noty function but still user can close noty in V2 by click on message