https://github.com/codeyellowbv/marionette-notifications
Show notifications in a Marionette region
https://github.com/codeyellowbv/marionette-notifications
Last synced: 11 months ago
JSON representation
Show notifications in a Marionette region
- Host: GitHub
- URL: https://github.com/codeyellowbv/marionette-notifications
- Owner: CodeYellowBV
- Created: 2016-01-15T17:13:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-01T10:51:51.000Z (almost 10 years ago)
- Last Synced: 2025-01-16T11:26:54.129Z (over 1 year ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# marionette-notifications
Shows sexy notifications in a region.
Some features:
- When a notification is added that already has the same content as a notification that already exists, no notification is added.
- A notification will disappear after 3 seconds. When hovering over a notification, it will not disappear.
Installation:
```
$ npm install marionette-notifications --save
```
## Usage
First make sure you have `underscore`, `marionette` and `backbone` as a dependency.
Now create a view where you listen to all events that need to trigger a notification (I will name it `view/notification.js`);
```js
var Notification = require('marionette-notifications').CollectionView;
var vent = require('vent');
module.exports = Notification.extend({
initialize: function () {
Notification.prototype.initialize.call(this);
// Listen to events here, e.g.:
this.listenTo(vent, 'user:delete', this.onUserDelete);
},
onUserDelete: function () {
// Let's create the notification, shall we?
this.info({
content: 'User is successfully deleted.'
});
}
});
```
In your template, create a div: `