title: KineticJS. draw image with onClick event
body: <p>I'm trying to draw image into KineticJS canvas with onClick event, but it doesn't work.
  Error like this: Uncaught TypeError: Cannot call method 'add' of undefined
  imageObj.onload
  How to make stage &amp; layer vars visible for drawImage function? Hope smb can help me cause I've already haven't ideas to do this</p>
  
  <pre><code>    var stage = new Kinetic.Stage({
          container: "container",  // div with id 'container'
          width: 578,
          height: 500,                
      });
  
      var layer = new Kinetic.Layer();        
  
      function drawImage(src) {       
          var imageObj = new Image();
          imageObj.onload = function() {
              var image = new Kinetic.Image({
                  x: 100,
                  y: 110,
                  image: imageObj,
                  draggable: true,
              });
  
              layer.add(image);
  
              stage.add(layer);
          };
  
          imageObj.src = src;
      }                         
  </code></pre>
  
  <p>...
  img src="testImage.jpg" onclick="drawImage(this.src);"</p>