title: addEventListener execute JSX only the first time
body: <p>as the subject suggests while testing some listeners I found this strange behavior: the addEventListener does get triggered, the callback get called but the evalScript invoking the JSX runs only the first time.</p>
  
  <p>This is how I'm doing it:  </p>
  
  <p><strong>ext.JS</strong>  </p>
  
  <pre><code>function doSomething(){
   document.getElementById("placeholder").innerHTML += "+";
   csInterface.evalScript("JSXdoSomething",
      function(result){
          document.getElementById("docName").innerHTML += result + ", ";
      });
  }
  
  var csInterface = new CSInterface();
  csInterface.addEventListener("documentAfterActivate",doSomething);
  </code></pre>
  
  <p><strong>in the JSX I have:</strong>  </p>
  
  <pre><code>JSXdoSomething = pleaseDo()
  function pleaseDo(){
      return app.activeDocument.name;
  }  
  </code></pre>
  
  <p>now, when switching between documents, this line get executed every time: </p>
  
  <pre><code>document.getElementById("placeholder").innerHTML += "+";  
  </code></pre>
  
  <p>but the <strong>evalScript</strong> works only the first time.  </p>
  
  <p><em>PSA: if you already have a document opened and you open the extension documentAfterActivate gets fired.</em>  </p>
  
  <p>E.g.:<br>
  we have 2 documents open: Doc1 and Doc2, the output I'm getting while switching between the two:
  <strong>"placeholder" = ++++++...</strong><br>
  <strong>"docName" = Doc1, Doc1, Doc1, Doc1...</strong></p>
  
  <p>I've also tried to call the evalScript in this way:<br>
  <strong>a) csInterface.evalScript("pleaseDo"</strong> ...<br>
  or<br>
  <strong>b) csInterface.evalScript("pleaseDo()"</strong> ...  </p>
  
  <p>for <strong>a)</strong> I get the same behavior as described above and for <strong>b)</strong> I get "EvalScript Error."</p>
  
  <p>I tried to change the JSX in this way:  </p>
  
  <pre><code>$._doSomething = function(){
     return app.activeDocument.name;
  }  
  </code></pre>
  
  <p>and call it like this:<br>
  <strong>csInterface.evalScript("$._doSomething"</strong> ...   </p>
  
  <p>I get the same behavior as before: the evalScript get executed only the first time and for the subsequent times the value stored in the return is always the name of the first Document.<br>
  I've also tried to put an <strong>alert</strong> in the JSX function and sure enough I don't get the pop-up every time I change the document but only the first time.</p>
  
  <p>Have you played with the events? Can you point me in the right direction?</p>