Gritter titles, text, image

596 views Asked by At

I have 3 conditions which would render 3 different gritter notifications. The condition results should change the image, text and title. Do I have to $.gritter.add({...}) for every single condition?

Or is there a way to declare just one gritter notification before any of the conditions are met, and then within each condition, set the title, text, image as they may apply to that condition?

It seems the only return value from $.gritter.add({...}) is a unique id, which is great for removal, but from first glance, I don't see a way into an added gritter item from inspecting the DOM in firebug.

Any help is appreciated

1

There are 1 answers

0
yardpenalty.com On

I know this is years later but this is how you change the properties/values of gritter:

var unique_id = $.gritter.add({
    // (string | mandatory) the heading of the notification
    title: '<i class="fa fa-4x fa-bell"></i>&nbsp;&nbsp;New Page Enhancement!',
    // (string | mandatory) the text inside the notification
    text: 'Visit "New Page Enhancements" by clicking on the notifications icon.',
    // (string | optional) the image to display on the left
    image: '../images/logo.png',
    // (bool | optional) if you want it to fade out on its own or just sit there
    sticky: true,
    // (int | optional) the time you want it to be alive for before fading out
    time: '',
    // (string | optional) the class name you want to apply to that specific message
    class_name: 'my-sticky-class'
});

The unique_id can be named for each instance of gritter you plan to roll out.