Looking for Prototype/script.aculo.us replacement on Rails? jRails project can be an answer if you prefer JQuery. Here is info from project site:

Features

jRails provides drop-in functionality for these existing Rails methods.

Prototype

  • form_remote_for
  • form_remote_tag
  • link_to_remote
  • observe_field
  • observe_form
  • periodically_call_remote
  • remote_form_for
  • submit_to_remote

Scriptaculous

  • draggable_element
  • drop_receiving_element
  • sortable_element
  • visual_effect

RJS

  • hide
  • insert_html
  • remove
  • replace
  • replace_html
  • show
  • toggle

Visual Effects

The visual effects in jRails are based on the new jquery-fx library. jRails currently uses a slightly modified version of jquery fx code to get some of the desired effects. This code is evolving and is subject to change. In the meatime, you can get a taste of the visual effects that are currently available.

Appear, Fade, Puff, BlindDown, BlindUp, BlindRight, BlindLeft, SwitchOff, SwitchOn, SlideDown, SlideUp, DropIn, DropOut, Shake, Pulsate, Squish, Fold, FoldOut, Grow, Shrink, Highlight

How to use

Just install and go! Once installed, the previous Prototype/script.aculo.us helpers will be replaced by jQuery ones. In order for them to function correctly, just include the appropriate javascript files in the head of your page.

1
2
3
4
5
<script src="/javascripts/jquery.js" type="text/javascript"></script>
<script src="/javascripts/jquery-ui.js" type="text/javascript"></script>
<script src="/javascripts/jquery-fx.js" type="text/javascript"></script>
<script src="/javascripts/jrails.js" type="text/javascript"></script>
<script src="/javascripts/jrails.js" type="text/javascript"></script>

You can also use the Rails javascript_include_tag helper with :default to load them automagically.

1
<%= javascript_include_tag :defaults %>

Install

To install the jRails plugin:

1
.script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails

Then copy the javascript files in the plugin folder to your javascripts directory.


Free Website Magazine: Know more than your competitors with Website Magazine

Don't forget to subscribe so you don't miss out on future posts!


Related Posts