Wednesday, September 5, 2012

Toggle div using ruby on rails

Hello Guys,
        Toggle is the function of prototype.js. We just have to use it to perform toggling.

eg.

html = "Toggle me <span id='collapse'>"
html << link_to_function(image_tag("arrow_normal.png", :style => 'border:none;'), "$('collapse').toggle();$('expand').toggle(); new Effect.Highlight('DIVID',{endcolor:'#ffffff', startcolor:'#ffffc8', duration:2.0}); return false;")
html << "</span>"    
html << "<span id='expand' style='display:none'>"
html << link_to_function(image_tag("arrow-down.png", :style => 'border:none;'), "$('collapse').toggle();$('expand').toggle();return false;")
html << "<div id='DIVID'> HELLO </div> </span>"

Initially it show the text as Toggle me with right arrow. but when you click on that i replace the right arrow to down arrow. And display the container area with text HELLO as per above eg.

No comments:

Post a Comment