javascript

Javascript Helpers

Provides functionality for working with JavaScript in your views.

Ajax, controls and visual effects


Functions

f link_to_function(name, function, **html_options) ...

Returns a link that'll trigger a JavaScript function using the onclick handler and return false after the fact.

Example:

link_to_function("Greeting", "alert('Hello world!')")

f button_to_function(name, function, **html_options) ...

Returns a link that'll trigger a JavaScript function using the onclick handler and return false after the fact.

Example:

button_to_function("Greeting", "alert('Hello world!')")

f escape_javascript(javascript) ...

Escape carriage returns and single and double quotes for JavaScript segments.

f javascript_tag(content, **html_options) ...

Returns a JavaScript tag with the content inside.

Example:

>>> javascript_tag("alert('All is good')")
'<script type="text/javascript">\n//<![CDATA[\nalert(\'All is good\')\n//]]>\n</script>'

See the source for more information.