mrt:flash-messages

v1.0.1Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

flash-messages Build Status

Package for displaying flash messages to the user. This is based on the chapter 'Creating a Meteorite Package' from the Discover Meteor Book and the foundation-flash-messages package.

This package integrates well with Bootstrap Alerts styles, but Bootstrap is not a dependency.

You can see a demo and their source code.

Note

The syntax has changed on version 0.2.0

Usage

Include the template somewhere in your index.html file:

1  {{> flashMessages}}

And then send messages:

1  FlashMessages.sendWarning("Message");
2  FlashMessages.sendError("Message");
3  FlashMessages.sendSuccess("Message");
4  FlashMessages.sendInfo("Message");

Note: sendAlert was deprecated, use sendWarning instead.

You can also send a group of messages sending an array of strings. This will be rendered on a ul li list:

1  FlashMessages.sendInfo(["Message 1", "Message 2", "Message 3"]);

Messages can also contain html:

1  FlashMessages.sendInfo("You can found <strong>Meteor</strong> <a href='http://meteor.com'>here</a>");

To clear messages:

1  FlashMessages.clear();

Only the seen messages will be cleared.

##Configure

You can configure globally the way the messages behave with FlashMessages.configure (the below sample shows the default values):

1  FlashMessages.configure({
2    autoHide: true,
3    hideDelay: 5000,
4    autoScroll: true
5  });
  • autoHide: set to true to make flash message fade after hideDelay milliseconds, set to false to require the user to click the close button on the message to dismiss it.
  • hideDelay: set the desired number of milliseconds for the flash message to be displayed (when autoHide is true).
  • autoScroll: set to true to enable auto scroll when a message is displayed, false to disable auto scroll. (Note: this can be set only globally.)

You can also set individual options on messages. This will override global configuration:

1  FlashMessages.sendWarning("Message", { autoHide: false });
2  FlashMessages.sendError("Message", { hideDelay: 2000 });
3  FlashMessages.sendSuccess("Message", { autoHide: true, hideDelay: 8000 });