Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are binding a handler 2500 times, instead make your function use either live or delegate like this:</p> <pre><code>$('li.product-code').live('click', function(event){ $('input.product-qty').live('keyup', function(){ </code></pre> <p><a href="http://api.jquery.com/live/" rel="nofollow noreferrer"><code>.live()</code></a> listens for the click to bubble up at the DOM level then executes the event with the context of the click source. This means you have <strong>one</strong> event handler instead of 2500 of them, meaning it's <strong>much</strong> faster and easier on the browser.</p> <p>If you have a container that wraps the replaced content that isn't replaced (remains across all AJAX calls), you can make it more local like this:</p> <pre><code>$('#container').delegate('li.product-code', 'click', function(event){ $('#container').delegate('input.product-qty', 'keyup', function(){ </code></pre> <p>The result of this is the event bubbles fewer times before being caught.</p> <p>Another pain point is probably the creation of the elements, can you post that code? There are often easy optimizations that yield a big performance boost there.</p> <p><strong>Update</strong></p> <blockquote> <p>As of jQuery 1.7, the <a href="http://api.jquery.com/live/" rel="nofollow noreferrer">.live()</a> method is deprecated. Use <a href="http://api.jquery.com/on/" rel="nofollow noreferrer">.on()</a> to attach event handlers. Users of older versions of jQuery should use <a href="http://api.jquery.com/delegate/" rel="nofollow noreferrer">.delegate()</a> in preference to <a href="http://api.jquery.com/live/" rel="nofollow noreferrer">.live()</a> - <a href="http://api.jquery.com" rel="nofollow noreferrer">JQuery Docs</a></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload