<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Unobtrusive JavaScript helpers in Rails 3</title>
	<atom:link href="http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3</link>
	<description>web development, ruby, javascript and other crazy things</description>
	<lastBuildDate>Sun, 30 May 2010 11:47:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Week 9 &#8211; T&#8217;was the week before Echelon - The Naked Startup</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-6732</link>
		<dc:creator>Week 9 &#8211; T&#8217;was the week before Echelon - The Naked Startup</dc:creator>
		<pubDate>Sun, 30 May 2010 11:47:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-6732</guid>
		<description>[...] and we didn&#8217;t want spaghetti Javascript littered all over our pretty site. Rails 3 promises unobtrusive Javascript along with drivers for all major Javascript libraries, and since we aren&#8217;t on Rails 3 yet, a [...]</description>
		<content:encoded><![CDATA[<p>[...] and we didn&#8217;t want spaghetti Javascript littered all over our pretty site. Rails 3 promises unobtrusive Javascript along with drivers for all major Javascript libraries, and since we aren&#8217;t on Rails 3 yet, a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HTML5 has custom data attributes &#124; yonkeltron</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-6276</link>
		<dc:creator>HTML5 has custom data attributes &#124; yonkeltron</dc:creator>
		<pubDate>Thu, 25 Mar 2010 15:13:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-6276</guid>
		<description>[...] technique are most likely to be found in the applications of RDFa. However, when looking at the new unobtrusive JavaScript helpers in the forthcoming Rails 3, I was tipped off to the huge scope of the new data- attributes in [...]</description>
		<content:encoded><![CDATA[<p>[...] technique are most likely to be found in the applications of <span class="caps">RDF</span>a. However, when looking at the new unobtrusive JavaScript helpers in the forthcoming Rails 3, I was tipped off to the huge scope of the new data- attributes in [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clemens Kofler</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-3648</link>
		<dc:creator>Clemens Kofler</dc:creator>
		<pubDate>Wed, 16 Sep 2009 13:06:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-3648</guid>
		<description>Listening to click events on the submit button doesn&#039;t work for certain cases - at least not to my knowledge. I, for example, usually don&#039;t click the submit button but hit return instead. As far as I know, that doesn&#039;t trigger a click event on the submit button.</description>
		<content:encoded><![CDATA[<p>Listening to click events on the submit button doesn&#8217;t work for certain cases &#8211; at least not to my knowledge. I, for example, usually don&#8217;t click the submit button but hit return instead. As far as I know, that doesn&#8217;t trigger a click event on the submit button.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: solnic</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-3617</link>
		<dc:creator>solnic</dc:creator>
		<pubDate>Thu, 10 Sep 2009 20:01:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-3617</guid>
		<description>jQuery.live(&#039;submit&#039;) will probably work on IE in a future version of jQuery.

There are other solutions to workaround that problem. One for instance (something I&#039;ve done in one of my recent projects) is to observe clicks on submit buttons and simply send an AJAX request based on the form that the submit button belongs to.

It could be something like:


&lt;pre lang=&quot;javascript&quot;&gt;
$(&#039;input[type=submit]&#039;).live(&#039;click&#039;, function() {
  var form = $(this).parents(&#039;form&#039;);
  if (form.attr(&#039;data-remote&#039;) != &#039;true&#039;) return; 
  $.ajax({ url : form.attr(&#039;action&#039;), type : form.attr(&#039;method&#039;) });
  return false;
});
&lt;/pre&gt;

You could obviously use different type of elements which would send our remote forms.</description>
		<content:encoded><![CDATA[<p>jQuery.live(&#8217;submit&#8217;) will probably work on IE in a future version of jQuery.</p>
<p>There are other solutions to workaround that problem. One for instance (something I&#8217;ve done in one of my recent projects) is to observe clicks on submit buttons and simply send an <span class="caps">AJAX </span>request based on the form that the submit button belongs to.</p>
<p>It could be something like:</p>

<div class="wp_codebox"><table><tr id="p1861"><td class="code" id="p186code1"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[type=submit]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> form <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parents</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>form.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'data-remote'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'true'</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span> 
  $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> url <span style="color: #339933;">:</span> form.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'action'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> type <span style="color: #339933;">:</span> form.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'method'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You could obviously use different type of elements which would send our remote forms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nicolas</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-3616</link>
		<dc:creator>nicolas</dc:creator>
		<pubDate>Thu, 10 Sep 2009 19:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-3616</guid>
		<description>I&#039;ve written a blog post on how to achieve this, using CSS classes to do that. So you can keep the standards. Here is the post (http://www.notgeeklycorrect.com/english/2009/05/18/beginners-guide-to-jquery-ruby-on-rails/).

Regarding the HTML5, I thing it;s a really good choice to go ahead on HTML5, a bit worried about performances and users on IE ...</description>
		<content:encoded><![CDATA[<p>I&#8217;ve written a blog post on how to achieve this, using <span class="caps">CSS </span>classes to do that. So you can keep the standards. Here is the post (<a  href="http://www.notgeeklycorrect.com/english/2009/05/18/beginners-guide-to-jquery-ruby-on-rails/" rel="nofollow">http://www.notgeeklycorrect.com/english/2009/05/18/beginners-guide-to-jquery-ruby-on-rails/</a>).</p>
<p>Regarding the <span class="caps">HTML5,</span> I thing it;s a really good choice to go ahead on <span class="caps">HTML5, </span>a bit worried about performances and users on IE &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michelson</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-3591</link>
		<dc:creator>michelson</dc:creator>
		<pubDate>Tue, 08 Sep 2009 20:00:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-3591</guid>
		<description>maybe you should try lowpro for jquery or prototype, the Remote.link and Remote.form is in the box

cheers</description>
		<content:encoded><![CDATA[<p>maybe you should try lowpro for jquery or prototype, the Remote.link and Remote.form is in the box</p>
<p>cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: solnic</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-3583</link>
		<dc:creator>solnic</dc:creator>
		<pubDate>Tue, 08 Sep 2009 08:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-3583</guid>
		<description>I tried this code with jQuery 1.3.2 and it does work with submit event.

update: live with submit works on Firefox, Safari and Opera &lt;strong&gt;but not on IE.&lt;/strong&gt;</description>
		<content:encoded><![CDATA[<p>I tried this code with jQuery 1.3.2 and it does work with submit event.</p>
<p>update: live with submit works on Firefox, Safari and Opera <strong>but not on <span class="caps">IE.</span></strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: VixenVineyard</title>
		<link>http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3/comment-page-1#comment-3582</link>
		<dc:creator>VixenVineyard</dc:creator>
		<pubDate>Tue, 08 Sep 2009 08:19:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.solnic.eu/?p=186#comment-3582</guid>
		<description>jQuery.live() doesn&#039;t support submit event at this moment. You need to use the LiveQuery plugin at this moment (http://plugins.jquery.com/project/livequery/)</description>
		<content:encoded><![CDATA[<p>jQuery.live() doesn&#8217;t support submit event at this moment. You need to use the LiveQuery plugin at this moment (<a  href="http://plugins.jquery.com/project/livequery/" rel="nofollow">http://plugins.jquery.com/project/livequery/</a>)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
