title: jQuery: calling a function within an event handler's nameless function
body: <p>I want to know why this works:</p>
  
  <pre><code>$('#clientSearchFirstName').keyup(runLiveSearch);
  </code></pre>
  
  <p>But this doesn't:</p>
  
  <pre><code>$('#clientSearchFirstName').keyup(function() {
      runLiveSearch();
      });
  </code></pre>
  
  <p>The error returned for the latter has to do with the jQuery library (I have the minified version), apparently effected in some way:</p>
  
  <blockquote>
    <p>TypeError: f.nodeName is undefined (jquery.js)    </p>
    
    <p>...,h=h.slice(c.length),c.type=g,c.matches=d);if(!c)break}return
    b?h.length:h?bc.er...</p>
  </blockquote>
  
  <p>Is it impossible to call another function with an event handler's "default" function? For reference (I don't see why it would have to do with the contents of the function), here is the function:</p>
  
  <pre><code>function runLiveSearch() {
              var search_string = $(this).val();
              var which = this.id;
              which = which.replace("clientSearch",""); 
  
              if (search_string == '') {
                  $("#statusBox").fadeOut();
              }else{
                  $.ajax({
                      url: "echoSearchResults.php?searchQuery=" + search_string + "&amp;which=" + which, // ...etc
                      type: 'GET',
                      dataType: 'json',
                      success: function(data) {
                          var filler = '';
                          if (data &amp;&amp; data.length &gt; 0) {
                              if (data.length &lt; 30) {
                              filler = '&lt;span class="searchInfo"&gt;Found '+data.length+' results for "'+search_string+'":&lt;/span&gt; &lt;br /&gt;'; }
                              else { filler = '&lt;span class="searchInfo"&gt;Showing first 30 results for "'+search_string+'":&lt;/span&gt; &lt;br /&gt;'; }
                              filler = filler + '&lt;table id="search-results" cellpadding="2" border="1" cellspacing="1"&gt;&lt;tr&gt;&lt;td&gt;ID&lt;/td&gt;&lt;td&gt;First name&lt;/td&gt;&lt;td&gt;Last Name&lt;/td&gt;&lt;td&gt;Cell phone&lt;/td&gt;&lt;td&gt;Home phone&lt;/td&gt;&lt;td&gt;Work phone&lt;/td&gt;&lt;td&gt;Primary Phone&lt;/td&gt;&lt;/tr&gt;';
                              for (x=0;x &lt;= (data.length - 1);x++)
                              {
                                  filler = filler +'&lt;tr class="searchLink" id="csr'+data[x][0]+'" onclick="displayClientData(this.id); scrollTo(this.id)"&gt;&lt;td&gt;'+data[x][0]+'&lt;/td&gt;&lt;td&gt;' + data[x][1] + '&lt;/td&gt;&lt;td&gt;' + data[x][2] + '&lt;/td&gt;&lt;td&gt;'+convertphone(data[x][3],"touser")+'&lt;/td&gt;&lt;td&gt;'+convertphone(data[x][4],"touser")+'&lt;/td&gt;&lt;td&gt;'+convertphone(data[x][5],"touser")+'&lt;/td&gt;&lt;td&gt;'+convertphone(data[x][6],"touser")+'&lt;/td&gt;&lt;/tr&gt;';
                              }
                              filler = filler + '&lt;/table&gt;';
                          } else { filler = 'No search results found for "'+search_string+'".'; }
                          document.getElementById('statusBox').innerHTML = filler;
                      }
                  });
                  $("#statusBox").fadeIn();
              }       
          }
  </code></pre>