Search code examples
jquery-pluginsnoty

closing noty error popup when next error occures


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.


Solution

  • 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