Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

scriptaculous requirements

For some strange reason, a hidden element that will be worked on by scriptaculous must have its display:none style inline, within the element, and not from a css class.

<div id="flash_box" class="flash_box" style="display:none;">
        <div id="fb_content" class="fb_content">
                <%= flash[:warning] %>
        
="fb_close" class="fb_close" onclick="new Effect.BlindUp($('flash_box'), {duration:0.25})"> Close This span> </div>

The div 'flash_box' only works with scriptaculous when
style="display:none;"

is used _inline_.

Escaping single quotes in a javascript literal string

When you need to include multiple nested single quotes within a string of javascript to be executed, escape single quotes with a back slash as needed.

Example from within an .rhtml template

hide_warning = "window.setTimeout('Effect.BlindUp($(\\'flash_box\\'), {duration:.3})', #{@warning_timeout ||= 8000})"


In this example, Double backslashes are required since the blackslash itself needs to be escaped and included within the string of js to be executed by windown.setTimeout().

programmatically firing object event using javascript

Simply call the event of the object.

<select id='element_id' onChange="some_javascript_func">

<a href="#" onclick="$('element_id').onchange();">


Note that this uses Prototype's $ function to find the element.

More details here:
http://tinyurl.com/2b45me
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed