# Unobtrusive Javascript plugin

**URL:** <https://www.ruby-forum.com/t/unobtrusive-javascript-plugin/99341>\
**Category:** Rails\
**Created:** [July 21, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-plugin/99341 "2006-07-21T20:25:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ar1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d9b06d/32.png) [@ar1](https://www.ruby-forum.com/u/ar1)\
**Post date:** [July 21, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-plugin/99341/1 "2006-07-21T20:25:06Z")

</div>

Hi,

I downloaded the unobtrusive\_javascript pluing from this link  
([http://www.lukeredpath.co.uk/index.php/2006/06/06/introducing-unobtrusive-javascript-for-rails/](http://www.lukeredpath.co.uk/index.php/2006/06/06/introducing-unobtrusive-javascript-for-rails/))  
since I needed to have dynamic content in javascript (for a pop-up  
menu).

Unfortunately I have been unable to make the plugin work. I followed the  
instructions on the website, but for some reason the javascript doesnâ??t  
work (for example there is no mouseover). Iâ??ve obviously changed the CSS  
id to mine. In fact Iâ??ve tried with several ids. The WEbrick server logs  
tell me that /unobtrusive\_javascript/generate is being fetched ok. In  
the plugin controller, I did a â??putsâ? for the @behaviour object and that  
too has the correct behaviour that I passed using registerjsbehaviour.

I was wondering if someone has used this plugin and could point me in  
the right direction.

Thanks!

---

<div class="post-metadata">

**Author:** ![ar1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d9b06d/32.png) [@ar1](https://www.ruby-forum.com/u/ar1)\
**Post date:** [July 22, 2006, 1:09am UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-plugin/99341/2 "2006-07-22T01:09:18Z")

</div>

I’ve had a look at the code, I should be able to help you out.

Did you get any JavaScript errors?

Have a look in your public/scripts dir and check if event-selectors.js  
is there. If not change to the plugins directory and do:

rake update\_scripts

Also, if you use the firebug extension for firefox you’ll be able to  
more easily diagnose the problem by looking at what scripts are  
loaded.

---

<div class="post-metadata">

**Author:** ![ar1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d9b06d/32.png) [@ar1](https://www.ruby-forum.com/u/ar1)\
**Post date:** [July 22, 2006, 1:12am UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-plugin/99341/3 "2006-07-22T01:12:38Z")

</div>

Also make sure you have

\<%= javascript\_include\_tag :defaults %\>

In the head of your document.

---

<div class="post-metadata">

**Author:** ![ar1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d9b06d/32.png) [@ar1](https://www.ruby-forum.com/u/ar1)\
**Post date:** [July 23, 2006, 5:38am UTC](https://www.ruby-forum.com/t/unobtrusive-javascript-plugin/99341/4 "2006-07-23T05:38:36Z")

</div>

Dan, I fixed the problem by including the events-selectors.js file  
specifically. Initially I had \<%= javascript\_include\_tag :defaults %\>  
but it wasn’t working so I removed that didn’t try it again.

Dan W. wrote:

> Also make sure you have
> 
> \<%= javascript\_include\_tag :defaults %\>
> 
> In the head of your document.
