title: populate selectlist with json data in JQuery when the selectlist is loaded (not the document)
body: <p>I have a button on a form that is dynamically spawning a select list, which is supposed to be populated with json data, i have all of the json data being pulled in correctly my only issue is hooking the selectlist's onload event to fill itself with data, i know i could use $('#itemID').fillSelectlist() to fill it but the problem is my select list ID's are dynamically generated and i don't know of a way to concat a select like ( $("#item" + itemNum + "list") )</p>
  
  <p>my current code is below:</p>
  
  <pre><code>$.fn.fillSelect = function(data) {
  return this.clearSelect().each(function() {
      if (this.tagName == 'SELECT') {
          var dropdownList = this;
          $.each(data, function(index, optionData) {
              var option = new Option(optionData.Text, optionData.Value);
              if ($.browser.msie) {
                  dropdownList.add(option);
              }
              else {
                  dropdownList.add(option, null);
              }
          });
      }
  });
  </code></pre>
  
  <p>}</p>
  
  <p>I was attempting to hook this up to the onload of a select list like so:</p>
  
  <pre><code>$.fn.FillDDL = function() {
  $.getJSON("/Controller/GetFileCategories", null, function(data) {
      this.fillSelect(data);
  });
  
  &lt;select id="file1Category" name="file1Category" class="form_input_small" onload="fillDDL"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>any pointers?</p>
  
  <p>EDIT: my select lists are injected to the page as html stored in a jquery script with the onload="fillDDL" value but they aren't firing when they appear, if i set a script to do $('#file1Category').fillDDL in my document.ready() script it fires but errors, so I guess i am expanding my question to include why that onload isn't working and if there is another method i should be using?</p>
  
  <p>EDIT2: my fields are being added to the form like so:</p>
  
  <pre><code>$('#moreFiles').click(function() {
      $("&lt;div class='form_row'&gt;" +
          "&lt;div id='file" + FileCount + "row'&gt;" +
          "&lt;input type='button' class='form_input_small delete' value='X' onclick=\"$('#file" + FileCount + "row').empty()\" /&gt;" +
          "&lt;label for='file" + FileCount + "File' class='form_label_small'&gt;File&lt;/label&gt;" +
          "&lt;input type='file' class='form_input_small' name='file" + FileCount + "File' id='file" + FileCount + "File' /&gt;" +
          "&lt;label for='file" + FileCount + "Category' class='form_label_small'&gt;Category&lt;/label&gt;" +
          "&lt;select id='file" + FileCount + "Category' name='file" + FileCount + "Category' class='form_input_small'&gt;&lt;/select&gt;" +
          "&lt;/div&gt;&lt;/div&gt;&lt;br class='clear' /&gt;")
          .hide()
          .appendTo($('#fileDiv'))
          .fadeIn('fast');
      FileCount++;
  });
  </code></pre>