I am trying to use the [jQuery Tiny Pub/Sub][1]. However, I didn't even manage to use the code below to run a function on html. For example, how do I call publish1. How should I do that? Thanks.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
/*
jQuery pub/sub plugin by Peter Higgins ([email protected])
*/
(function($) {
var topics = {};
$.publish1 = function(topic, args) {
if (topics[topic]) {
var currentTopic = topics[topic];
for (var i = 0, j = currentTopic.length; i < j; i++) {
currentTopic[i].apply($, args || []);
}
}
};
$.subscribe1 = function(topic, callback) {
if (!topics[topic]) {
topics[topic] = [];
}
topics[topic].push(callback);
return {
"topic": topic,
"callback": callback
};
};
</script>
$.publish1()?