Project

rjs-if

0.0
No commit activity in last 3 years
No release in over 3 years
Add if/unless blocks to RJS
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.0.0
 Project Readme

JavaScript IF/UNLESS blocks support¶ ↑

This plugin introduces support for IF/UNLESS blocks to Rails’ javascript generator.

Usage¶ ↑

Lets say you want to produce javascript that will execute blind_down visual effect to show some DOM element unless it is already visible. To accomplish this you need an IF block:

update_page do |page|
  page << "if( !($('#{element_id}').visible()) ) {"
  page.visual_effect :blind_down, element_id
  page << "}"
end

Instead you can use if method that this plugin provides:

update_page do |page|
  page.unless "$('#{element_id}').visible()" do
    page.visual_effect :blind_down, element_id
  end
end

Also, you can make use of javascript element proxy in the expression:

update_page do |page|
  page.unless page[element_id].visible do
    page.visual_effect :blind_down, element_id
  end
end

Download¶ ↑

Download it from rubyforge.org/projects/js-if-blocks/ or via Rails plug in script:

./script/plugin install svn://rubyforge.org/var/svn/js-if-blocks/trunk/js-if-blocks

Bugs & Feedback¶ ↑

If you encounter any bugs or has some feature proposal, feel free to email it to

maxim.kulkin@gmail.com.