tap/app/views/orders/_order.html.erb
2014-11-25 13:09:55 +01:00

27 lines
551 B
Plaintext

<li id="order-<%= order.id %>">
<span class="products"></span>
<span class="timestamp">
Ordered <%= time_ago_in_words(order.created_at) %> ago.
</span>
</li>
<script charset="utf-8">
$(document).ready(function() {
//$(".products").empty()
var op = '<%=order.products%>'.replace(/&quot;/g , "\"" );
console.log(op);
var products = JSON.parse(op);
console.log(products)
$.each(products, function(i, product) {
$(".products").append("<p> - "+ i +": "+ product.number_of +"</p>");
});
});
</script>