title: onclick events don't work for ajax appended html using classic asp with Prestashop static html files
body: <p>I have been assigned to update a classic asp website with a Prestashop template called Autotune Responsive Prestashop Theme. My client wants all the ajax bells and whistles they see online in Template Monster. Template Monster made static html files for my client from this template which includes all the custom Prestashop javascript libraries. So far I am unable to use these custom Prestashop jquery/ajax libaries as they were intended so I have to write my own code to paginate, add to cart, show item popup, etc. Everything works great except for appending html. For example, pagination. When I view a list of parts in grid view and I click to append nine more parts, the html gets appended OK but onclick events to the Add To Cart button and "eye" icon popup are dead for the new items that were appended. Mouse over events are OK. Same issue when I append html to the cart popup - I see the added cart items in the cart popup but the "x" (delete) won't work when clicked although the color changes when moused over. It's as if I need to update something after appending. I'm stumped. Here is the pagination code:</p>
  
  <pre><code>    $(function() {
          $('#infiniteScrollMore').click(function(){
              var numItems = parseInt($('#NumItems').text());
              var pageNbr = parseInt($('#PageNbr').text()) + 1;
  
              $('#PageNbr').text(pageNbr);
  
              $.get('AppendParts.asp?PageNbr=' + pageNbr + '&amp;NumItems=' + numItems,function (data) {
  
                  $('.product_list').append(data);
  
                  numNextItems = parseInt(numItems) - (parseInt(pageNbr) * 9);
  
                  if (parseInt(numNextItems) &gt;= 9) numNextItems = 9;
  
                  setTimeout(function(){$('#NumNextItems').text(' (' + numNextItems + ')')},2000);
  
                  if ((parseInt(pageNbr) * 9) &gt;= parseInt(numItems))
                  {
                      $('#infiniteScrollMore').hide();
                      setTimeout(function(){$('#NewSearchButton').show();},2000);
                  }
              });
          });
      });
  </code></pre>
  
  <p>I am just using .append to append html to the product_list ul. AppendParts.asp writes the html, which is...</p>
  
  <pre><code>    &lt;li class="ajax_block_product"&gt;
          &lt;div class="product-container" itemscope itemtype="https://schema.org/Product"&gt;
              &lt;div class="left-block"&gt;
                  &lt;div class="product-image-container"&gt;
                      &lt;div class="tmproductlistgallery rollover"&gt;
                          &lt;div class="tmproductlistgallery-images opacity"&gt;
                              &lt;a class="product_img_link cover-image" href="product.asp?PartNbr=&lt;%=pageCache("PartNbr")%&gt;&amp;amp;StockNbr=&lt;%=pageCache("StockNbr")%&gt;&amp;amp;ProductCode=&lt;%=pageCache("ProductCode")%&gt;&amp;amp;MachineType=&lt;%=pageCache("MachineType")%&gt;&amp;amp;Model=&lt;%=pageCache("Model")%&gt;&amp;amp;Category=&lt;%=pageCache("Category")%&gt;&amp;amp;SubCategory=&lt;%=pageCache("SubCategory")%&gt;" title="&lt;%=pageCache("Description") &amp; " " &amp; pageCache("Make") &amp; " " &amp; pageCache("PartNbr") &amp; " " &amp; pageCache("Class")%&gt;" itemprop="url"&gt;
                                  &lt;img class="img-responsive" src="http://&lt;%=theImage%&gt;" alt="" title="&lt;%=pageCache("Description") &amp; " " &amp; pageCache("Make") &amp; " " &amp; pageCache("PartNbr") &amp; " " &amp; pageCache("Class")%&gt;"&gt;
                              &lt;/a&gt;
                              &lt;a class="product_img_link rollover-hover" href="product.asp?PartNbr=&lt;%=pageCache("PartNbr")%&gt;&amp;amp;StockNbr=&lt;%=pageCache("StockNbr")%&gt;&amp;amp;ProductCode=&lt;%=pageCache("ProductCode")%&gt;&amp;amp;MachineType=&lt;%=pageCache("MachineType")%&gt;&amp;amp;Model=&lt;%=pageCache("Model")&amp;amp;Category=&lt;%=pageCache("Category")%&gt;&amp;amp;SubCategory=&lt;%=pageCache("SubCategory")" title="&lt;%=pageCache("Description") &amp; " " &amp; pageCache("Make") &amp; " " &amp; pageCache("PartNbr") &amp; " " &amp; pageCache("Class")%&gt;" itemprop="url"&gt;
                                  &lt;img class="img-responsive" src="http://&lt;%=theImage%&gt;" alt="" title="&lt;%=pageCache("Description") &amp; " " &amp; pageCache("Make") &amp; " " &amp; pageCache("PartNbr") &amp; " " &amp; pageCache("Class")%&gt;"&gt;
                              &lt;/a&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="functional-buttons"&gt;
                          &lt;div class="qv-wrap"&gt;
                              &lt;a class="quick-view" data-id="&lt;%=pageCache("ProductCode") &amp; ":" &amp; pageCache("StockNbr") &amp; ":" &amp; pageCache("PartNbr")%&gt;" href="#" onclick="return false;" data-fancybox-type="ajax" data-type="ajax" data-href="#" title="Quick View"&gt;&lt;/a&gt;
                          &lt;/div&gt;
                          &lt;div class="compare"&gt;
                              &lt;a class="add_to_compare" href="product.asp?PartNbr=&lt;%=pageCache("PartNbr")%&gt;&amp;amp;StockNbr=&lt;%=pageCache("StockNbr")%&gt;&amp;amp;ProductCode=&lt;%=pageCache("ProductCode")%&gt;&amp;amp;MachineType=&lt;%=pageCache("MachineType")%&gt;&amp;amp;Model=&lt;%=pageCache("Model")%&gt;&amp;amp;Category=&lt;%=pageCache("Category")%&gt;&amp;amp;SubCategory=&lt;%=pageCache("SubCategory")%&gt;" data-id-product="&lt;%=pageCache("ProductCode") &amp; ":" &amp; pageCache("StockNbr") &amp; ":" &amp; pageCache("PartNbr")%&gt;" title="Detailed View"&gt;&lt;/a&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>... abbreviated a bit. Here is the fancybox code:</p>
  
  <pre><code>$(function() {
          $('.quick-view').click(function(){
              var idStrArray = $(this).attr('data-id');
              var idStr = idStrArray.split(':');          
              var productCode = idStr[0];
              var stockNbr = idStr[1];
              var partNbr = idStr[2];
  
              $.fancybox({
                  'closeClick': true,
                  'hideOnContentClick': true,
                  'padding': 0,
                  'width': 1021,
                  'autoDimensions': false,
                  'height': 500,
                  'type': 'iframe',
                  'tpl': {wrap: '&lt;div class="fancybox-wrap fancybox-quick-view" tabIndex="-1"&gt;&lt;div class="fancybox-skin"&gt;&lt;div class="fancybox-outer"&gt;&lt;div class="fancybox-inner"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;'},
                  'href': 'product-popup.asp?PartNbr=' + partNbr + '&amp;ProductCode=' + productCode + '&amp;StockNbr=' + stockNbr,
                  'beforeClose': function() {}
                  }
              });
          });
      });     
  </code></pre>
  
  <p>What am I missing?</p>