title: Close modal which has been created in another event function
body: <p>On my first event I will open a mbox dialog. mbox is a kind of extention for bootbox, which is for showing a modal. I need mbox to use another template as modal content.</p>
  
  <p>So in the modal will be loaded with the content of createElement-Template. If the user has done some input changes the modal should be closed. Therefore there is the function <code>modal("hide")</code>. 
  But as <code>bbox</code> is been set in the first template-event and the closing of the modal will be done in the second template-event, I got problems to close the modal.</p>
  
  <p><strong>events</strong></p>
  
  <pre><code>Template.main.events({
      'submit form': function(event, template) {
          event.preventDefault();
  
          var bbox = mbox.dialog({
              title: 'title',
              message: Template.createElement
          });
      }
  });
  
  Template.createElement.events({
      'change input': function(event, template) {
          bbox.modal('hide');
      }
  });
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The above problem works with a global var. Thanks for to Adam for that.</p>
  
  <p>But not I would like to destroy a modal in a meteor package, which was created by another <strong>package</strong>. I tried to use a global var and I tried to use <code>api.export()</code>. But still it doesn't work. I also tried to work with Sessions.</p>
  
  <p><strong>package-graph/lib/client/graph.js</strong></p>
  
  <pre><code>var bbox;
  CanvasManager = {
      onShowAddToolTip (element) {
          bbox = mbox.dialog({ // &lt;-- Create Modal
              title: "Title",
              message: Template.search, // &lt;-- Loading Template search with just one input field with typeahead
          });
      },
  }
  
  CanvasManger.create(...);
  </code></pre>
  
  <p><strong>package-graph/lib/package.js</strong></p>
  
  <pre><code>api.export('bbox');
  </code></pre>
  
  <p>The second package provide a typeahead-searchbox (<code>sergeyt:typeahead</code>). By creating the modal in the first package, the Template will be loaded in the modal (<code>helloludger:mbox</code>). Now the user can search via typeahead and select an item. After the selection the modal should be destroyed by `modal('hide').</p>
  
  <p><strong>package-search/lib/client/events.js</strong></p>
  
  <pre><code>Template.searchMain.onRendered(function() {
      Meteor.typeahead.inject();
  });
  </code></pre>
  
  <p><strong>package-search/lib/client/helper.js</strong></p>
  
  <pre><code>Template.search.helpers({ // &lt;-- getting the data for the input typeahead
      searchData: function() {
          return [
              {
                  name: 'cat1',
                  valueKey: 'title',
                  displayKey: 'title',
                  header: '&lt;h3 class="category-name"&gt;Category&lt;/h3&gt;',
                  template: 'searchResults',
                  local: function() {
                      return Collection.find().fetch();
                  }
              }
          ]
      },
      selected: function(event, suggestion) { // &lt;-- by selecting an item, I can process the data and remove the modal
              // do something
              bbox.modal('hide'); // &lt;!-- destroy modal
              return;
          }
      }
  });
  </code></pre>