<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'Updating the Image link to add_to_cart for AJAX (pg 130)' | Pragmatic Forums</title>
    <link>http://forums.pragprog.com/forums/66/topics/421</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>Updating the Image link to add_to_cart for AJAX (pg 130) posted by Scott Gardner @ Fri, 09 May 2008 21:08:11 -0000</title>
      <description>&lt;p&gt;Replying to my own topic to report a problem with degrading this functionality when JS is turned off (pg 138). As it stands, using the code I posted above, clicking on the image with JS off does nothing.&lt;/p&gt;


	&lt;p&gt;Why is that? It&amp;#8217;s calling the same action, so the request.xhr? conditional should work the same as clicking the Add to Cart button, right?&lt;/p&gt;


	&lt;p&gt;I tried refactoring the link as follows, which I got to work but the display got fouled up and my initial attempts to fix the &lt;span class="caps"&gt;CSS&lt;/span&gt; didn&amp;#8217;t work (e.g., display: inline;, wrapping it in a new div class, etc.).&lt;br /&gt;&lt;pre&gt;&lt;code&gt;
&amp;lt;% form_remote_tag :url =&amp;gt; {:action =&amp;gt; :add_to_cart, :id =&amp;gt; product} do %&amp;gt;
    &amp;lt;%= image_submit_tag(product.image_url) %&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;Is this the correct approach (and thus I just need to fix my &lt;span class="caps"&gt;CSS&lt;/span&gt;), or is there a better way?&lt;/p&gt;</description>
      <pubDate>Fri, 09 May 2008 21:08:11 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:421:2772</guid>
      <author>Scott Gardner</author>
      <link>http://forums.pragprog.com/forums/66/topics/421</link>
    </item>
    <item>
      <title>Updating the Image link to add_to_cart for AJAX (pg 130) posted by Scott Gardner @ Fri, 09 May 2008 17:05:01 -0000</title>
      <description>&lt;p&gt;The end of lesson assignments previously had us make the image a link to add_to_cart. Once you switch over to using an Ajax cart, your link will no longer work. Here&amp;#8217;s my code to update that link:&lt;/p&gt;


	&lt;p&gt;depot/app/views/store/index.html.erb&lt;br /&gt;&lt;pre&gt;&lt;code&gt;
&amp;lt;%= link_to_remote image_tag(product.image_url), :url =&amp;gt; {:action =&amp;gt; 'add_to_cart', :id =&amp;gt; product} %&amp;gt;
&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 09 May 2008 17:05:01 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:421:2770</guid>
      <author>Scott Gardner</author>
      <link>http://forums.pragprog.com/forums/66/topics/421</link>
    </item>
  </channel>
</rss>
