title: How to use deferred.when with eventlistner and eventhandler?
body: <p>I am trying to use one Deferred.when statement which can return an object after the  completion of an eventhandler. My code looks like something below. Can someone guide me how to  make it work? I am using dojo 1.7.</p>
  
  <pre><code>define(["dojo/_base/declare","dojo/_base/lang", "dojo/_base/xhr",
      "dojo/_base/json","dojo/_base/Deferred","dijit/registry","dojo/_base/connect",
      "dojo/query","dojo/on","dojo/dom-attr","dojo/dom","dojo/has","dojo/json","dojo/dom-style"],
      function(declare,lang,xhr,json,Deferred,registry,connect,$,on,attr,dom,has,json,domStyle)
      {
  
          declare("model.Item", [], 
          {
              deferred:null,
              item:null,
  Load: function(){
                 this.deferred = new Deferred();
  
                 var overlay = registry.byId("readFromStore");
                     overlay.show();
                     Deferred.when(connect.connect(registry.byId("storeReadOK"),"onClick",this,this.loadFromStorage), (return (this.deferred)));
                    // I want modification for the above line.
                  }
  
  loadFromStorage:function()
                  {
              // Do something here
                 this.deferred.callback(this.item);
  
             }
       return model.Item;
          }
      );
  </code></pre>
  
  <p>I also tried this below code for the Load function but it is also not working.</p>
  
  <pre><code>    Load: function(){
  
       this.deferred = new Deferred();
  
                connect.connect(registry.byId("storeReadOK"),"onClick",this,this.loadFromStorage);
                  var overlay = registry.byId("readFromStore");
                      overlay.show();
                          //  Deferred.when(connect.connect(registry.byId("storeReadOK"),"onClick",this,this.loadFromStorage),(overlay.hide()));
  
                  return this.deferred;
       }
  </code></pre>