Trigger an event in jquery
<p>Here is my code structure, that I saw from someone else and am trying to make sense of it. I believe its a closure style and not a plugin style? maybe someone can clarify this for me if its a closure style. </p>

<p>Kind of plugin style. Here are some general questions.</p>

<ol>
<li>So the variable NP is in the global namespace correct? and just used
as a reference to the closure and its inner public methods. </li>
<li>Using NP (which is the namespace ) before a method is just a way to
reference that method from outside the closure.</li>
<li>If I set NP to null does it destroy and allow for garbage collection
of everything inside of NP including all variables.</li>
</ol>

<p>This is the bigger question here so I'll put it out on its own.
When I trigger an event from an inner method <strong>actionMethod()</strong>
I want to be able to receive that event, from lets say another js file. For example home.js</p>

<p><strong>home.js</strong></p>

<pre><code>    $(function(){

      NP.bind("CHANGED", event_handler);

     function event_handler(evt, data ){
       // do something....
     }

     $('#button').click(function(){
      // call my public method in my NP plugin
      NP.PublicMethod();
     });

  });
</code></pre>

<p><strong>Closure ( style )</strong></p>

<pre><code>var NP = function(namespace){

     var innerVariable = "the outside scope can't here me";

     finction innerMethod(){
        //does some inner functionality to the closure
     }  

     namespace.PublicMethod = function(){
       // does some calling of inner function.
      // user can access this method from the myplugin directly.
      // example: NP.PublicMethod();
     }

     function actionMethod(){
       // trigger an event so others outside this closure can react
       namespace.trigger("CHANGED");
     }

    }(NP || {});
</code></pre>

<p>Please if someone can answer the first 3 questions then the larger question about the triggering of events. Thanks in advance</p>

<p><strong>Update:</strong></p>

<p>Something that ShankarSangoli made an example of by triggering the event from a DOM element. 
The issue here is I have a dom element that is acting as a close button inside my closer, but home.js has no idea of it or no reference to, nor should it. So I need a way for to listen on the NP object level for events fired from it. As a test I tried the below code and it worked. No idea why as its not a DOM element, but in most languages you can fire an event from most generic objects. And in this case NP is in fact an object, or am I going mad in thinking its an object.</p>

<p><strong>closure Object</strong></p>

<pre><code>   function actionMethod(){
           // trigger an event so others outside this closure can react
           $(namespace).trigger("CHANGED");
         }
</code></pre>

<p>home.js</p>

<pre><code>$(TWCCP).bind("CLOSED_POPUP", onClosePopup);
</code></pre>

<p>Now I'm very confused about this. How is this possible now???</p>
