Forum: Ruby on Rails [ANN] Unobtrusive Javascript for Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Luke R. (Guest)
on 2006-06-07 02:24
I made a brief post on here the other day about this and now I can
proudly present the initial release of our unobtrusive_javascript
plugin for Rails. We'll be working with Dan W. of Vivabit to roll in
much of the functionality in his own as-yet unreleased
unobtrusive_javascript plugin into a single plugin.

This is essentially a preview release and probably not suitable for
use on a production site just yet but we hope it will be production
ready ASAP.

So here's the important details!

The blog post:
http://www.lukeredpath.co.uk/index....ript-for-rails/

The documentation/information:
http://opensource.agileevolved.com/...usiveJavascript

The source:
http://opensource.agileevolved.com/...avascript/trunk

All comments and ideas are welcome. Enjoy!

** Apologies if this ends up here twice but gmail is acting up
Luke R. (Guest)
on 2006-06-07 13:27
Brian H. (Guest)
on 2006-06-07 17:35
(Received via mailing list)
Very very cool.
Brian H. (Guest)
on 2006-06-07 17:35
(Received via mailing list)
I get invalid links for those... 404 for the first, and nothing useful
for the other two.
Is it just me?
Robert D. (Guest)
on 2006-06-07 18:42
Hello,

I too am having a problem with this plugin. I found the
event-selectors.js file in the assets folder of the plugin and put it
into the "public/behaviours" folder which worked for it but I am getting
an error when it looks for dynamic.js in the same location. I am using
the latest version of Prototype. The exact errors I am getting (in
Firefox 1.5.0.4) is "EventSelectors is not defined." Thank you for your
help.

Sincerely,

Robert D.
Luke R. (Guest)
on 2006-06-07 20:40
Robert D. wrote:
> Hello,
>
> I too am having a problem with this plugin. I found the
> event-selectors.js file in the assets folder of the plugin and put it
> into the "public/behaviours" folder which worked for it but I am getting
> an error when it looks for dynamic.js in the same location. I am using
> the latest version of Prototype. The exact errors I am getting (in
> Firefox 1.5.0.4) is "EventSelectors is not defined." Thank you for your
> help.
>
> Sincerely,
>
> Robert D.

Hi Robert - there is no need to copy anything into your public folders -
both the event-selectors.js and dynamic.js contents are rendered at
runtime by a built-in controller that comes with the plugin.

There was a bug where the controller action responsible for rendering
the contents of event-selectors.js was looking for it in the wrong
place. I fixed this earlier so please run an update and have another go.

Cheers
Luke
Robert D. (Guest)
on 2006-06-07 22:29
Luke,

That fixed the problem. Thank you very much for such a quick fix. Works
like a charm! I intend on using it asap. Much obliged.

- Robert D.

Luke R. wrote:

> Hi Robert - there is no need to copy anything into your public folders -
> both the event-selectors.js and dynamic.js contents are rendered at
> runtime by a built-in controller that comes with the plugin.
>
> There was a bug where the controller action responsible for rendering
> the contents of event-selectors.js was looking for it in the wrong
> place. I fixed this earlier so please run an update and have another go.
>
> Cheers
> Luke
Gernot K. (Guest)
on 2006-06-09 11:17
Hi Luke

I like the idea of this plugin very much. However, I have no luck
getting it to work. Here's what I'm trying to do:

I have a partial that renders several boxes containing some text. Each
box is in a div with a unique id like this:

<div class="entry-card" id="entry<%= entry.id.to_s %>" >
...
</div

I would like to apply some effect for a mouseover and I tried it like
this:

<% register_js_behaviour "#entry9:mouseover", visual_effect(:highlight,
"entry9", :duration => 0.5) %>

The selector is hardcoded for testing purposes and there is a div with
id "entry9" on the page. But nothing happens :-( What am I doing wrong
here ?

The prototype-scripts are installed and working, I am using effects in
my rjs-files.

Any help would be very appreciated

Best regards

Gernot
Luke R. (Guest)
on 2006-06-09 14:44
Hi Gernot,

I'm not sure why it isn't working - can I advise you to try loading up
your page in Firefox using the Firebug extension? You'll be able to
select the dynamic.js file and view the javascript that has been
generated.

Once you've tried this, please submit a bug on our Trac at
http://opensource.agileevolved.com

Cheers
Luke

Gernot K. wrote:
> Hi Luke
>
> I like the idea of this plugin very much. However, I have no luck
> getting it to work. Here's what I'm trying to do:
>
> I have a partial that renders several boxes containing some text. Each
> box is in a div with a unique id like this:
>
> <div class="entry-card" id="entry<%= entry.id.to_s %>" >
> ...
> </div
>
> I would like to apply some effect for a mouseover and I tried it like
> this:
>
> <% register_js_behaviour "#entry9:mouseover", visual_effect(:highlight,
> "entry9", :duration => 0.5) %>
>
> The selector is hardcoded for testing purposes and there is a div with
> id "entry9" on the page. But nothing happens :-( What am I doing wrong
> here ?
>
> The prototype-scripts are installed and working, I am using effects in
> my rjs-files.
>
> Any help would be very appreciated
>
> Best regards
>
> Gernot
This topic is locked and can not be replied to.