Friday, February 10, 2006

Playing with AJAX and Scriptaculous in rails


onClick="<%= visual_effect(:highlight, 'test'%>"
visual_effect(:puff, 'tests')
visual_effect(:shake, 'tests')
visual_effect(:DropOut, 'tests')
visual_effect(:SwitchOff, 'tests')
visual_effect(:Squish, 'tests')
visual_effect(:Pulsate, 'tests')
visual_effect(:Fold, 'tests')
visual_effect(:BlindDown, 'tests')
visual_effect(:grow, 'tests')

  post to Del.icio.us

AJAX Script.aculo.us and Rails

Scriptaculous has a new version (1.51) out. Today, I decided to install it as the version I had didn't support the toggle combination effect. For my latest project Adoppt, I needed the toggle feature. Although the Rails on edge (v 1.1) has the support for this added, I didn't want to upgrade yet.

Script.aculo.us has some wonderful effects. The documentation of its CoreEffects lists the options that can be used with most effects. These options include:

duration: Duration in seconds, given as a float. Defaults to 1.0
fps: Frames per second (default:25, max:100)
transition: "Sets a function that modifies the current point of the animation, which is between 0 and 1. Following transitions are supplied: Effect.Transitions.sinoidal (default), Effect.Transitions.linear, Effect.Transitions.reverse, Effect.Transitions.wobble and Effect.Transitions.flicker."
from: "Sets the starting point of the transition, a float between 0.0 and 1.0. Defaults to 0.0."
to: "Sets the end point of the transition, a float between 0.0 and 1.0. Defaults to 1.0."
sync: Sets whether the effect should render new frames automatically (which it does by default). If true, you can render frames manually by calling the render() instance method of an effect. This is used by Effect.Parallel().
queue: "Sets queuing options. When used with a string, can be ‘front’ or ‘end’ to queue the effect in the global effects queue at the beginning or end, or a queue parameter object that can have {position:’front/end’, scope:’scope’, limit:1}. For more info on this, see Effect Queues."



Ajaxian blog has some pointers on using the new Script.aculo.us 1.51 effects on Rails:

visual_effect :toggle_slide, ‘element’
visual_effect :toggle_blind, ‘element’
visual_effect :toggle_appear, ‘element’



I tried using them on Rails 1.0 but obviously it didn't work.
  post to Del.icio.us

eXTReMe Tracker