I have having trouble with the code below; I cant make it run in a JavaScript function. This just shows a toast message at the top of the page. The below code just runs on pageLoad and works fine. But when I am putting it in a function it doesn't work and produces this error:
Cannot read property 'add' of undefined
jQuery(function ($) {
$('#gritter-error').on(ace.click_event, function(){
$.gritter.add({
title: 'This is a warning notification',
text: 'Just add a "gritter-light" class_name to your $.gritter.add or globally to $.gritter.options.class_name',
class_name: 'gritter-error' + (!$('#gritter-light').get(0).checked ? ' gritter-light' : '')
});
return false;
});
})