title: Javascript bootstrap modal calling function
body: <p>My code is like below:</p>
  
  <pre><code>function OnApply(runFunc) {
      $("#myCfmModal").modal('show');    
      $("#myCfmModal").find("#myCfmModalText").html("Apply change now?"); 
      $("#myCfmModal").find("#myCfmModalHeader").css("background","#cccccc");
      $("#myCfmModal").one('click', '#okbtn', runFunc);            
  }
  
  function cool() {
      alert("cool!");
  }
  </code></pre>
  
  <p>I have a problem running the code above. I call the <code>OnApply(cool())</code> as below:</p>
  
  <pre><code>&lt;button class="btn btn-success" onclick="OnApply(cool())"&gt;Apply&lt;/button&gt;
  </code></pre>
  
  <p><code>OnApply(cool())</code> will show a modal box and run a function <code>cool()</code>. What I want to do is to run function <code>cool()</code> when I click the OK button in the modal box. However the <code>cool()</code> function will always run first before I click the OK button. Any idea what went wrong?</p>