<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>sukria.net &#187; scriptaculous</title>
	<atom:link href="http://www.sukria.net/en/archives/category/scriptaculous/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sukria.net/en</link>
	<description>Being a debian geek, that's a way of life!</description>
	<pubDate>Wed, 10 Dec 2008 10:01:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>link_to_draggable</title>
		<link>http://www.sukria.net/en/archives/2007/03/20/link_to_draggable/</link>
		<comments>http://www.sukria.net/en/archives/2007/03/20/link_to_draggable/#comments</comments>
		<pubDate>Tue, 20 Mar 2007 11:03:44 +0000</pubDate>
		<dc:creator>sukria</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[scriptaculous]]></category>

		<guid isPermaLink="false">http://www.sukria.net/en/archives/2007/03/20/link_to_draggable/</guid>
		<description><![CDATA[It&#8217;s been a couple of months since I&#8217;ve started playing with Rails. I must say (fear the buzz) that it just kicks your ass.
One of the stuff I really like in Rails is the scriptaculous library integration: you have a couple of easy-to-use functions for generating JavaScript voodoo. One of them being draggable_element() which allows [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a couple of months since I&#8217;ve started playing with <a href="http://www.rubyonrails.org/">Rails</a>. I must say (fear the buzz) that it just kicks your ass.</p>
<p>One of the stuff I really like in Rails is the <a href="http://script.aculo.us/">scriptaculous</a> library integration: you have a couple of easy-to-use functions for generating JavaScript voodoo. One of them being draggable_element() which allows you to drag a random object of the DOM and drop it somewhere.</p>
<p>I&#8217;m using that function in one of my Rails project and I discovered a bug that occurs with last versions of Mozilla Firefox (does not seem to affect IE). When using draggable_element() on a link item a conflict occurs when dropping the link on the page, making the browser to follow the link. It looks like something went wrong with the overload of the &#8220;onMouseDown&#8221; event.</p>
<p>As I just had to use <a href="http://wiki.rubyonrails.org/rails/pages/ActionView::Helpers::ScriptaculousHelper.draggable_element">draggable_element()</a> on link items and as I found nothing about that issue after Googling a bit, I started writing a fix which led to a new helper called link_to_draggable().</p>
<p>The idea behind the fix is simple (and of course a bit crappy-but-working): a flag is set to tell if the link should be followed or not. That flag will be updated accordingly when a regular click is performed, and when a drag starts.</p>
<p><a href="http://www.sukria.net/code/link_to_draggable.html">Here is how to use it.</a></p>
<p>The first two args are the same as the ones used by link_to(): the name and url of the link. The third argument is a hashtable of options to pass to the link_to() call. The last argument is a hashtable of options to pass to draggable_element().</p>
<p>Now <a href="http://www.sukria.net/code/link_to_draggable_helper.html">here is the code</a>, if you like to use that helper thingy in your Rails app.</p>
<p>Of course that could be done better, the best thing to do would be to fix draggable_element() itself, if you ask me.<br />
Anyway I had to fix that bug, and in the meantime, that solution just does the job for me, maybe it does also for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sukria.net/en/archives/2007/03/20/link_to_draggable/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
