title: turn this into a jquery function?
body: <p>I am using the code below to do pagination on a table (please do not suggest any prebuilt ones)</p>
  
  <pre><code>function tablejax(url, start, count) {
      $('#tablejaxButton').attr("disabled", "true");
      $('#tablejaxOverlay').fadeIn('slow');
      $.ajax({
          type: "GET",
          url: url,
          data: "start="+start+"&amp;count="+count+"&amp;identifier="+$('#tablejaxButton').val(),
          success: function(data){
              setTimeout(function(){
                  $('#myTable tbody').append(data);
                  $('#myTable tr td div').slideDown('slow');
                  $("html:not(:animated),body:not(:animated)").animate({
                      scrollTop: $('body').attr("scrollHeight")
                      }, 1000 );
                  $("table").trigger("update");
              }, 1000);
              setTimeout(function(){
                  $('#tablejaxOverlay').fadeOut('slow');
                  $('#tablejaxButton').removeAttr('disabled');
              }, 1000);
          }
      });
  }
  </code></pre>
  
  <p>however i am currently calling it through </p>
  
  <pre><code>$('#tablejaxButton').click(function() {
          tablejax(this.name,  tcount, 20);
          tcount = tcount+20;
      })
  </code></pre>
  
  <p>there are a few problems with this,
  but the ones i want to change are.</p>
  
  <p>I want to be able to call <code>$('#tableID').tablejax('url', 'identifier', 'count');</code><br>
  eg <code>$('#tableUsers').tablejax('get_members.php', 27, 20);</code></p>
  
  <p>it would automatically attach an onclick event to <code>#tableUsersButton</code> (tableID + Button) </p>
  
  <p>i want the function itself to keep track of where we should start from,
  currently i am using  </p>
  
  <pre><code>tcount = 20;  
  //do stuff  
  tcount = tcount +20; 
  </code></pre>
  
  <p>which is not ideal.</p>
  
  <p>what is the easiest way to do this?</p>
  
  <p>note: the function should make an assumption that the <code>count</code> that is passed into it has already been loaded into the table, eg if you call <code>$('#tableUsers').tablejax('get_members.php', 27, 20);</code> then the first 20 rows would already be loaded into the table via server side processing.</p>
  
  <p><hr />
  <strong>Update</strong><br />
  To simplify my question.</p>
  
  <p>I need to be able to call <code>$('#tableID).tablejax(--initial params here--);</code>
  on document ready,</p>
  
  <p>this would basically get a function ready by filling out some default params (eg identifier, url, ect)
  this would also add on onclick event handler to <code>$('#tableIDButton')</code> which when clicked would call something like <code>$('#tableIDButton').tablejax('next');</code></p>
  
  <p>this approach is used as sometimes i need to call the pagination using another trigger.</p>
  
  <p>all i need to know is</p>
  
  <ul>
  <li>How to register a function in jquery: <strong>Answered</strong></li>
  <li>How to register the click event when the function is called <strong>Answered:</strong> <em>Turns out I can register a click even from anywhere not just document ready</em></li>
  <li>How to call an 'action' in the function when it is not the initial call
   <em>(initial call should use the parameters, subsequent calls should call an 'internal function)</em></li>
  </ul>