title: CasperJS inject javascript via this.evaluate
body: <p>Today I tried to inject some javascript logic into remote page using CasperJS with PhantomJS together.</p>
  
  <p>Well, I'm quite surprised because of that:</p>
  
  <pre><code>casper.then(function() {
      console.log(this.evaluate(function() {
          function myMethod() {
              return 'Any thing?!';
          }
          return myMethod();
      }));
      console.log(this.evaluate(function() {
          return myMethod();
      }));
  });
  </code></pre>
  
  <p>I tried many combinations... Like:</p>
  
  <pre><code>casper.evaluate(...)
  this.evaluate(...)
  casper.page.evaluate(...) &lt;- directly to phantomJS
  this.page.evaluate(...)   &lt;- as above
  </code></pre>
  
  <p>First case gives me exactly what I want. But next call to evaluate act as an idiot, which never saw executed code above.</p>
  
  <p>I just want to change variables, functions, and other over remote site js runtime.</p>
  
  <p>Can anybody tell me why this is happening?
  Greetings.</p>