It’s a great day here at Joe Zim’s JavaScript Blog and surely a great day for the users of the JZ Publish/Subscribe jQuery plugin. This plugin has now been updated to version 1.2 and has gained probably the best feature it could gain at this point in its life and something that, arguably, maybe should have already been included with the plugin.
In this release we introduce context. Now, instead of all callback functions being run within the context of the jQuery
object, you can pass in an optional 3rd parameter to the $.subscribe
function that will define the context in which the callback is executed. This means the you can now use the this
keyword within your callback functions and know it’ll be the object you want it to be. Also, now when no context is given, a blank object ({}
) will be used as the context.
JZ Publish/Subscribe Documentation and Download
The JZ Publish/Subscribe Project Page has already been updated with new documentation and a link to download the new version. You can see an example of how to use this feature in the example code on the project page or by looking below.
1 | var obj = { |
I sincerely hope that you enjoy this new feature and that it is helpful in the development of your JavaScript. If you make a cool JavaScript app using this, you should send me a link via the Contact Me page so I can see. I might even show it off to the rest of the readers in a post, with your permission. Anyway, have a great rest of your weekend (or week if you don’t read this until after the weekend is over) and Happy Coding!