title: Ajax generated content and jquery event binding
body: <p>I have a page that displays products. The products are displayed via a ajax request. Included with the products are the pagination buttons. Here is my 
      $('document').ready(function(){</p>
  
  <pre><code>    $.ajax({
              url: '&lt;?=base_url().'catalog/show_listings';?&gt;',
              type:'POST',
              dataType: 'json',
              success: function(data){
                      $('#result_container').html(data);
                  }, // End of success function of ajax form
               complete : function(){
                      $('ul#pag-link &gt; li &gt; a').click(function(){
  
                          var link = $(this).attr('href')
  
                          $.ajax({
                              url: '&lt;?=base_url().'catalog/show_listings';?&gt;',
                              type:'GET',
                              dataType: 'json',
                              success: function(listings){
                                      $('#result_container').html(listings);
                                  } // End of success function of ajax form       
                           }); // End of ajax call                            
  
                          return false;
                      });
                  }
              }); // End of ajax call
  </code></pre>
  
  <p>On success of the first ajax call I  get the listings and displays them in div #result_container. Then on complete of that same ajax call I create a on click for the anchors in the unordered list #pag-
  link (the pagination buttons). This should return the next set of listings and again display it in #result_container, it will also again load the pagination buttons. I do this on complete because I cant do it earlier, as the pagination buttons are not present on binding.</p>
  
  <p>Here is the problem, to make it work I would have to again in the ajax complete add the onclick event for the pagination buttons. I will have to do this for every ajax load of more products and the pagination. </p>
  
  <p>THis is obviously not the right approach. Any suggestions?</p>