$(function(){
/**
initialize the plugin wherever you want to see messages
the first param should be the options, specify a ui
framework if you are using one, then send in an array of
events to respond to, with options
**/
$("#messages").envelope(
{uiFramework : 'bootstrap'}, //can also be jquerui or none
[
{
name : 'test.success', //name of event to resond to
message: 'Success saving test.', //message to show
type: 'success', //type of message, success, info, error
callback : function(){console.log("Success!");}
}, //callback to execute once the message is shown
{
name : 'test.error',
message : 'Error saving test.',
type : 'error',
callback : function(){console.log("Oh Noes!");}
},
{
name : 'test.untyped',
message : 'Untyped saving test.',
callback : function(){console.log("What do do?");}
}
]
);
//all we have to do on our elements, or anywhere in our code
//is trigger an event to display a message
$("#successButton").on('click',function(){
$(this).trigger('test.success');
});
$("#errorButton").on('click',function(){
$(this).trigger('test.error');
});
$("#untypedButton").on('click',function(){
$(this).trigger('test.untyped');
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.