Skip to content
This repository has been archived by the owner on Sep 6, 2020. It is now read-only.

nnnnathann/backbone-global-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backbone Global Events

Extends base backbone to include a globalEvents singleton. Useful for application-wide events.

Usage

var MenuButton = Backbone.View.extend({
  events: {
    'click': 'toggle'
  },
  // Triggers event on global object
  toggle: function () {
    this.globalEvents.trigger('sidebar:toggle');
  }
});

var Sidebar = Backbone.View.extend({
  initialize: function () {
    this.globalEvents.on('sidebar:toggle', this.toggle, this);
  },
  // Will fire whenever sidebar:toggle event is detected
  // globally
  toggle: function () {
    this.$el.toggle();
  }
});

About

Global events rail for Backbone

Resources

Stars

Watchers

Forks

Packages

No packages published