title: How to use jQuery dialog with fullcalendar select callback?
body: <p>I have a fundamental confusion about how jQuery, and probably javascript work.  I keep having the same issue, how to pass parameters to jQuery functions so that their methods in turn can call functions using those variables.  Here is my most recent example:</p>
  
  <p>I am using fullcalendar plugin.  If I click on the calendar, it fires a callback method 'select'.  The select callback is automatically given certain parameters: 'startDate' 'endDate', etc.  What I want is to open a jQuery dialog to gather additional information and then post the new event to the server.  Along the lines of this:</p>
  
  <pre><code>$('calendar').fullcalendar({
  ...
  select: function (startDate, endDate) {
      $('#newEventPopup').dialog('open');
  </code></pre>
  
  <p>in the html I have something like this:</p>
  
  <pre><code>&lt;div title = 'How cool is this event?' id='newEventPopup'&gt;
      &lt;select id='coolness'&gt;
          &lt;option value = 'super'&gt;Super!&lt;/option&gt;
          &lt;option value = 'cool'&gt;Cool&lt;/option&gt;
          &lt;option value = 'dorky'&gt;Dorky&lt;/option&gt;
          &lt;option value = 'lame'&gt;Lame!&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>finally, I would like to add a button to the dialog to post the fullcalendar variables as well as the new variable to the server:</p>
  
  <pre><code>var coolness = $('#coolness');
  $('#newEventPopup').dialog({
      modal: true,
      autoOpen: false,
      ...
      button: {
          Save : function (){
              $.ajax({
                  url: 'sample.php'
                  type: 'POST'
                  data: {
                      'start' : startDate,
                      'end' : endDate,
                      'coolness' : coolness
                   }
                   success: $('calendar').fullCalendar('refetchEvents')
               }
           }
       }
  });
  </code></pre>
  
  <p>I simply don't understand how to build this, or where to place the code so that the dialog 'save' button 'knows' what the variables 'startDate' 'endDate' and 'coolness' all mean.  I should mention that I am originally a Java programmer, and I am still struggling with JavaScript function based variable scope.</p>
  
  <p>I have had this problem with many such jQuery methods where I want one method to point to some external function (like the select callback method invoking $.dialog) which in turn executes another method (like like the button callback method invoking the $.ajax function) but how do you pass parameters to $.ajax or $.dialog so their own methods can use those values?</p>
  
  <p>Thanks,</p>