Search code examples
javascriptnotifyjs

Complete HTML in notify.js


I am using library Notify js for showing success or error messages on my php web page.
When I use normal text like

$.notify("Changes are made successfully", "success");

Then it works fine.

But sometimes, I need to show message in unordered list like as follows:

var message = '<p> Please correct following errors and then try again </p><ul><li>value1 is wrong</li><li>value 3 is wrong</li><li>value 5 is wrong</li></ul>';
$.notify(message, "error");

Then message is shown as it is, means whole html is displaying, instead I want to display like

Please correct following errors and then try again

 - value1 is wrong
 - value3 is wrong
 - value5 is wrong

Any suggestion would be highly appreciated!


Solution

  • you can add an own Class with the HTML Content like a Template System.

    $.notify.addStyle('saved', {
      html: 
        "<p>Saved blabla...</p>"
    });
    
    $.notify(..., { 
      style: 'saved'
    });