Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery ajax issue
    primarykey
    data
    text
    <p>I've been at this bit of code for a while, but am not sure what I'm doing wrong. Basically I want to create a loop that prints out all items in a cart. If I take the loop out, it prints the item just added, but when I add the loop in, it breaks. </p> <p>I'm not too familiar with jQuery/JSAON, so if anyone could point out where I might be going wrong, that would be great.</p> <p>(edit - full js files)</p> <pre><code>var ShoppCartAjaxHandler = function (cart) { (function($) { var display = $('#shopp-cart-ajax'); display.empty().hide(); // clear any previous additions var item = $('&lt;ul class="sidecart_list"&gt;&lt;/ul&gt;').appendTo(display); $.each(cart.items, function() { $("&lt;li&gt;&lt;/li&gt;").html("&lt;strong&gt;"+this.quantity+"&lt;/strong&gt;"+this.name).appendTo(item); }); //$('&lt;li&gt;&lt;/li&gt;').html('&lt;strong&gt;'+cart.Item.quantity+'&lt;/strong&gt; x '+cart.Item.name).appendTo(item); $('&lt;li&gt;&lt;/li&gt;').html('&lt;strong&gt;Subotal&lt;/strong&gt; '+asMoney(cart.Totals.subtotal)).appendTo(item); $('&lt;li&gt;&lt;/li&gt;').html('&lt;strong&gt;Shipping&lt;/strong&gt; '+asMoney(cart.Totals.shipping)).appendTo(item); $('&lt;li&gt;&lt;/li&gt;').html('&lt;strong&gt;Total&lt;/strong&gt; '+asMoney(cart.Totals.total)).appendTo(item); if ($('#shopp-cart-items').length &gt; 0) { $('#shopp-cart-items').html(cart.Totals.quantity); $('#shopp-cart-total').html(asMoney(cart.Totals.total)); } else { $('.widget_shoppcartwidget p.status').html('&lt;p class="status_info"&gt;&lt;strong&gt;&lt;span id="shopp-cart-items"&gt;'+cart.Totals.quantity+'&lt;/span&gt;&lt;/strong&gt; x &lt;span id="shopp-cart-total"&gt;'+cart.Item.name+'&lt;/span&gt;&lt;/p&gt;&lt;p class="status_info"&gt;&lt;strong&gt;Subtotal&lt;/strong&gt; &lt;span id="shopp-cart-subtotal"&gt;'+asMoney(cart.Totals.subtotal)+'&lt;/span&gt;&lt;/p&gt;&lt;p class="status_info"&gt;&lt;strong&gt;Shipping&lt;/strong&gt; &lt;span id="shopp-cart-shipping"&gt;'+asMoney(cart.Totals.shipping)+'&lt;/span&gt;&lt;/p&gt;&lt;p class="status_info"&gt;&lt;strong&gt;Total&lt;/strong&gt; &lt;span id="shopp-cart-total"&gt;'+asMoney(cart.Totals.total)+'&lt;/span&gt;&lt;/p&gt;'); } display.slideDown(); })(jQuery) } </code></pre>
    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. 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