title: A Function Which Returns Parent Functions
body: <p>I am having issues with some code. Basically I use jquery to run a callback function upon a button click. My issue is that the entire listening setup is within another function. When the jquery event fires I want to return the parent function, but I can’t figure out how.</p>
  
  <p>Thanks,</p>
  
  <p>-Alex</p>
  
  <pre><code>function placeObject(object) {
  
          $("#button").click( function() { 
  
              $(".fields").remove()   
              $("#curser" + object).remove()  
              $("#curser" + object).css("pointer-events","none");
              $("#curser" + object).css("display","none")
              $("#submitObject").css("display","none")
              $("#cancelCreation").css("display","none")
              $(".newObjectButton").css("display", "inline")
              zooming = true
  
          });
  
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>That function is called by this one:</p>
  
  <pre><code>function createObject(object) {
  
      $("#button").css("display","inline")
  
      if (object == "one thing") {
          placeObject(object)
      }
      else if (object == "another thing") {
          differentFuntion(object)
      }
  
  }
  </code></pre>
  
  <p>That function is called by this:</p>
  
  <pre><code>$(".newObjectButton").click( function() {
  
      createObject($(this).attr("id"))
  
  }); 
  </code></pre>
  
  <p>In an attempt to clarify my exact goal:</p>
  
  <p>I don't want to have a function return a function like this:</p>
  
  <pre><code>funtion a() {
      return b
  }
  funtion b() {
      alert("b")
  }
  </code></pre>
  
  <p>where the result would be an alert box saying "b"</p>
  
  <p>I want the return value of function a to be a signal which returns the encapsulating parent function b like this:</p>
  
  <pre><code>function a() {
  
      function b() {
           return return //whatever value forces the parent function to return
      }
  
  }
  </code></pre>