small medium large xlarge

24 Mar 2013, 07:30
Aaron Dufall (2 posts)

I’m trying to get this feature working, but I can seem to track down the problem. As best I can tell I have followed the book exactly, but when I click on a image nothing happens. I’ve tried chrome and safari, the result is the same in both. I checked in the chrome developer tool that the coffeescript was being compiled and it shows the javascript code.


<% if notice %>
	<p id="notice"><%= notice %></p>
<% end %>
<h1>Your Pargmatic Catalog</h1>
<% cache ['store', Product.latest] do %>
	<% @products.each do |product| %>
		<% cache ['entry', product] do %>
	    <div class="entry">
		    <%= image_tag(product.image_url) %>
		    <h3><%= product.title %></h3>
		    <p><%= sanitize(product.description) %></p>
		    <div class="price_line" >
			    <span class="price"><%= number_to_currency(product.price) %></span>
			    <%= button_to 'Add to cart', line_items_path(product_id: product), remote: true %>
	  <% end %>
	<% end %>
<% end %>


$(document).on "page:change", ->
  $('.store .entry > img').click ->


24 Mar 2013, 07:45
Aaron Dufall (2 posts)

Found the answer in the errata


➤ $(document).on “page:change”, -> ➤ $(‘.store .entry > img’).click -> ➤ $(this).parent().find(‘:submit’).click()

The above code does not work for me. I added “ready” to the first line and it works now, this is how it should look:

$(document).on “ready page:change”, ->–Nadeem

  You must be logged in to comment