title: Call a javascript function dynamically in jquery dialog function
body: <p>I want to call a function as parameter in jQuery dialog when the yes button is pressed. I am using the following code but this is not working.</p>
  
  <pre><code>function showYesNoAlertMsg(divId,optFunction){
   //window[optFunction].apply(null, Array.prototype.slice.call(arguments, 2));
  $('#'+divId).dialog('open');
  $('#'+divId).dialog({
              autoOpen: true,
              width: 400,
              height: 175,
              modal: true,
              resizable: false,
              buttons: {
                  "Yes": function() {
                   window[optFunction].apply(null, 
                                       Array.prototype.slice.call(arguments, 2));
                         $(this).dialog("close");
                  },
                  "No": function() {
                         $(this).dialog("close");
                  }
              }
                });   
               }
  
         function newfunc(a,b){
              alert(a+'--'+b);
            }
  
  
         &lt;input type="button" name="alert" id="alert" 
              onclick="showYesNoAlertMsg('boxDivId','newfunc','aaaaa','bbbbb');"/&gt;
  
       &lt;div id="boxDivId"&gt;
           hello
        &lt;/div&gt;
  </code></pre>
  
  <p>When I click on the button named "alert" this the function <code>showYesNoAlertMsg</code> is called and it shows the dialog box of id "boxDivId" perfectly but I want to call a function named "newFunc" on the yes button. I passed this function as a parameter but it is not working in the dialog property. If I uncomment the first commented line in <code>showYesNoAlertMsg</code>, This line works fine and calls the function "newFunc" perfectly. but the same line is not working in Yes button. Please tell me.</p>
  
  <p>Thanks</p>