jquery-boilerplate / jquery-patterns

A variety of jQuery plugin patterns for jump starting your plugin development
1.59k stars 242 forks source link

publish event works only on page load #20

Open ktadikamalla opened 11 years ago

ktadikamalla commented 11 years ago

If we publish any notification based on some click event then that event is not sub scribed. if you invoke the below method based on some button click event then it does not perform the actions in subscribe event.

$("#testPlugin").testSubscribe().trigger("eventPublished");

But if we perform the below step on page load then it works.

$("#testPlugin").testSubscribe(); $("#testPlugin").testSubscribe().trigger("eventPublished");

yckart commented 11 years ago

That is the standard procedure: Initialize the plugin >> work with it...

ktadikamalla commented 11 years ago

Hi, it is really rare that we publish any notifications on ready event, most of the notifications would be on any events like button click or text box leave events, if we are not able to initialize plugin and publish notifications on events like button click I am trying to understand the work flow for this plugin what are the scenarios we can use this plugin just on ready event at the time of page load?

addyosmani commented 11 years ago

This is true (re: notifications being broadcast on interactions with the page). I need to re-check this pattern but the publish events should be possible even after the plugin has been initialized to be really useful. Perhaps we need to consider simplifying this down a bit.