# Unobtrusive javascript...what if?

**URL:** <https://www.ruby-forum.com/t/unobtrusive-javascript-what-if/62545>\
**Category:** Rails\
**Created:** [June 6, 2006, 1:30am UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-what-if/62545 "2006-06-06T01:30:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukeredpath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9de0a6/32.png) [@lukeredpath](https://www.ruby-forum.com/u/lukeredpath)\
**Post date:** [June 6, 2006, 1:30am UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-what-if/62545/1 "2006-06-06T01:30:52Z")

</div>

What if…you could produce accessible, unobtrusive javascript, using  
Rails built-in javascript/prototype helpers, with just one extra line  
of code in your layout, a plugin, and one small enhancement to the  
helpers. Something like this:

[php]  
\<% form\_remote\_tag :controller =\> ‘foo’, :action =\> ‘bar’,  
:unobtrusive =\> true %\>

# which produces
[/php]

But which still acts as an ajax form? You would simply handle the  
response for ajax and non ajax requests using Rails’ responds\_to  
function.

In addition, what if you could attach javascript functionality to your  
page elements in a Behaviour-like fashion, but using pure Ruby,  
anywhere in your view, but loaded from an external Javascript file?

Sorry to tease. Stay tuned, we have something very cool to show off in  
the next day or two. You will be able to find more information on  
[http://opensource.agileevolved.com](http://opensource.agileevolved.com) in days to come, or stay tuned to  
my blog tomorrow for more.

Apologies for the blatant promotion but we think people will like  
this. People have asked for unobtrusive JS in Rails for a while. Could  
it be here at last?

Cheers  
Luke R.

> **[Luke Redpath - Freelance Ruby, Rails and iOS app developer / London / Essex / UK](https://lukeredpath.co.uk/)**
>
> Experienced freelance and contract developer offering Ruby, Rails and iOS app development services for iPhone, iPad and other iOS platforms. Based in Colchester, Essex, London and remote.

> **[AgileEvolved.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=agileevolved.com)**
>
> Own this domain today. We make your shopping experience easy. Friendly and quick customer service.

---

<div class="post-metadata">

**Author:** ![lukeredpath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9de0a6/32.png) [@lukeredpath](https://www.ruby-forum.com/u/lukeredpath)\
**Post date:** [June 6, 2006, 1:52am UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-what-if/62545/2 "2006-06-06T01:52:23Z")

</div>

Left the BB code tags from the forum post I made over at  
SitePoint…how embarrasing 😉

On 6/6/06, Luke R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Luke R.  
> [http://www.lukeredpath.co.uk](http://www.lukeredpath.co.uk)  
> [http://opensource.agileevolved.com](http://opensource.agileevolved.com)

–  
Cheers,  
Luke R.

> **[Luke Redpath - Freelance Ruby, Rails and iOS app developer / London / Essex / UK](https://lukeredpath.co.uk/)**
>
> Experienced freelance and contract developer offering Ruby, Rails and iOS app development services for iPhone, iPad and other iOS platforms. Based in Colchester, Essex, London and remote.
