Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 691 Bytes

README.md

File metadata and controls

27 lines (19 loc) · 691 Bytes

##Online Demo http://jsfiddle.net/bzr5npdj/

####Why do you need this?

When you need to have multiple view models communicate with each other, you usually have to do something like this data-bind="click: $parent[2].action"

This method is messy and unreliable, because if the order of the view models change, then your view will break.

Instead, you can send a message from the HTML and have the ViewModel subscribe to it:

####HTML File

data-bind="message: {topic: 'topicName', event: 'click'}"

####JS File

postbox.subscribe(function() {
  alert("hello");
}, self, "topicName");

How to install it

Look at demo.html