<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vision Master Designs &#187; Prototype, Script.aculo.us</title>
	<atom:link href="http://visionmasterdesigns.com/category/wp/ajax/javascript-frameworks/prototype-scriptaculous/feed/" rel="self" type="application/rss+xml" />
	<link>http://visionmasterdesigns.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 02 Aug 2010 12:09:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Really Easy Form/Field Validation using Prototype+Scriptaculous</title>
		<link>http://visionmasterdesigns.com/really-easy-formfield-validation-using-prototypescriptaculous/</link>
		<comments>http://visionmasterdesigns.com/really-easy-formfield-validation-using-prototypescriptaculous/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 15:51:07 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Prototype, Script.aculo.us]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Script.aculo.us]]></category>

		<guid isPermaLink="false">http://visionmasterdesigns.com/?p=1101</guid>
		<description><![CDATA[Hey Guys, Its been a while since I have started my final year Project called &#8220;OptimaPrime- The Enterprise Project Management System&#8221;. Most of you must have heard of project management systems. It helps enterprises manage their projects, lets them keep it on schedule, helps them allocate resources etc. I needed to perform form Validation since [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 0 0 0.6em 0.6em;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fvisionmasterdesigns.com%2Freally-easy-formfield-validation-using-prototypescriptaculous%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fvisionmasterdesigns.com%2Freally-easy-formfield-validation-using-prototypescriptaculous%2F&amp;source=rowoot&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Hey Guys,</p>
<p>Its been a while since I have started my final year Project called &#8220;OptimaPrime- The Enterprise Project Management System&#8221;. Most of you must have heard of project management systems. It helps enterprises manage their projects, lets them keep it on schedule, helps them allocate resources etc.<br />
I needed to perform form Validation since I had a lot of forms and it had lot of fields. I googled for good form validation plugins for Prototype + Scriptaculous (Since I have got really used to this cool library) and thats when I found <a href="http://tetlaw.id.au/view/javascript/really-easy-field-validation" target="_blank">Dexagogo&#8217;s Really Easy Field Validation plugin</a>.</p>
<p style="text-align: center;"><span id="more-1101"></span><img class="attachment wp-att-1105 centered" src="http://visionmasterdesigns.com/wordpress/wp-content/uploads/2009/02/validation1.thumbnail.jpg" alt="validation1" width="300" height="225" /></p>
<p>A very useful and a simple to use form validator for all kinds of forms. It has neat Fade IN/Fade OUT effects too. Custom classes can be defined, custom validations can be defined. It validates fields for a lot of different type of scenarios.</p>
<ul>
<li><code>required</code> (not blank)</li>
<li><code>validate-number</code> (a valid number)</li>
<li><code>validate-digits</code> (digits only)</li>
<li><code>validate-alpha</code> (letters only)</li>
<li><code>validate-alphanum</code> (only letters and numbers)</li>
<li><code>validate-date</code> (a valid date value)</li>
<li><code>validate-email</code> (a valid email address)</li>
<li><code>validate-url</code> (a valid URL)</li>
<li><code>validate-date-au</code> (a date formatted as; dd/mm/yyyy)</li>
<li><code>validate-currency-dollar</code> (a valid dollar value)</li>
<li><code>validate-selection</code> (first option e.g. &#8216;Select one&#8230;&#8217; is not selected option)</li>
<li><code>validate-one-required</code> (At least one textbox/radio element must be selected in a group &#8211; see below*)</li>
</ul>
<p>For more information on how to use this plugin visit  <a href="http://tetlaw.id.au/view/javascript/really-easy-field-validation" target="_blank">Dexagogo&#8217;s Website</a>. You can also check out a demo of this script at action <a href="http://tetlaw.id.au/upload/pages/really-easy-field-validation/" target="_blank">HERE</a>. It has very good documentation on how to use this plugin. Thanks Dexagogo. Although if you guys have any doubt on how to use it, I`ll be glad to help you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://visionmasterdesigns.com/really-easy-formfield-validation-using-prototypescriptaculous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial : Overlay a AJAX Spinner in the center of Web Page using Prototype</title>
		<link>http://visionmasterdesigns.com/tutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype/</link>
		<comments>http://visionmasterdesigns.com/tutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 11:51:52 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript Frameworks]]></category>
		<category><![CDATA[Prototype, Script.aculo.us]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Script.aculo.us]]></category>
		<category><![CDATA[Spinner]]></category>

		<guid isPermaLink="false">http://visionmasterdesigns.com/?p=1063</guid>
		<description><![CDATA[This tutorial is specially for beginners who are wondering how to place an AJAX Spinner. Its very simple guys. Just read below to find out. To those people who have wondered how to show the spinner image + loading message when any ajax request is made and to hide the spinner image + loading message [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 0 0 0.6em 0.6em;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fvisionmasterdesigns.com%2Ftutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fvisionmasterdesigns.com%2Ftutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype%2F&amp;source=rowoot&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This tutorial is specially for beginners who are wondering how to place an AJAX Spinner. Its very simple guys. Just read below to find out.</p>
<p>To those people who have wondered how to show the spinner image + loading message when any ajax request is made and to hide the spinner image + loading message when the request is successfully completed, this tutorial will help you out in achieving it and also teaches you how to show this loading box in the center of the browser screen and grey out the background contents with cool fade effects.</p>
<h3>Index :</h3>
<ul>
<li>Page 1 : <a href="http://visionmasterdesigns.com/tutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype/2/">Introduction</a></li>
<li>Page 2 : <a href="http://visionmasterdesigns.com/tutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype/2/">Required HTML/Javascript Code/CSS</a></li>
<li>Page 3 : <a href="http://visionmasterdesigns.com/tutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype/3/">Complete Code of Demo</a></li>
</ul>
<h3>Pre-Requisites :</h3>
<p>A little bit of CSS,HTML knowledge and know-how of Prototype, Scriptaculous.</p>
<p><span id="more-1063"></span></p>
<h3>Source/Demo :</h3>
<div style="margin: 0pt auto; text-align: center; width: 320px;"><a href="http://www.visionmasterdesigns.com/demo/spinner/" target="_blank"><br />
<img style="margin-right:10px;" src="http://visionmasterdesigns.com/wordpress/wp-content/themes/VMD3/images/demo.jpg" border="0" alt="View Demo" width="147" height="72" /></a><a href="http://www.visionmasterdesigns.com/demo/spinner/spinner-source.zip"><img src="http://visionmasterdesigns.com/wordpress/wp-content/themes/VMD3/images/source.jpg" border="0" alt="Download Source" width="147" height="72" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://visionmasterdesigns.com/tutorial-adding-a-ajax-spinner-in-the-center-of-web-page-using-prototype/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Tutorial : Auto Completer using Prototype, Script.aculo.us</title>
		<link>http://visionmasterdesigns.com/tutorial-auto-completer-using-prototype-scriptaculous/</link>
		<comments>http://visionmasterdesigns.com/tutorial-auto-completer-using-prototype-scriptaculous/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 13:35:43 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript Frameworks]]></category>
		<category><![CDATA[Prototype, Script.aculo.us]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Script.aculo.us]]></category>

		<guid isPermaLink="false">http://www.visionmasterdesigns.com/?p=770</guid>
		<description><![CDATA[How many of you have always dreamt of creating an Auto Suggest Box. I bet everyone must have seen one of these somewhere or the other. if you use Gmail to send mails, you might recall that while typing the To address, Gmail shows a probable list of users from your address book. Nowadays most [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 0 0 0.6em 0.6em;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fvisionmasterdesigns.com%2Ftutorial-auto-completer-using-prototype-scriptaculous%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fvisionmasterdesigns.com%2Ftutorial-auto-completer-using-prototype-scriptaculous%2F&amp;source=rowoot&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>How many of you have always dreamt of creating an Auto Suggest Box. I bet everyone must have seen one of these somewhere or the other. if you use Gmail to send mails, you might recall that while typing the To address, Gmail shows a probable list of users from your address book. Nowadays most of the modern browsers also have this Auto Suggest control built in them, i.e when the user begins to type in a text box, a menu appears below the text offering completion suggestions. </p>
<p>Today I am going to teach you how to create an Auto Suggest Box using Prototype, Script.aculo.us. The script.aculo.us auto suggest box (autocompleter) replicates this control, but gives the developer control of the probable suggestions.</p>
<p>Index</p>
<ul>
<li>Page 1 : <a title="Introduction" href="http://www.visionmasterdesigns.com/2008/10/tutorial-auto-completer-using-prototype-scriptaculous/">Introduction and </a></li>
<li>Page 2 : <a title="Auto Suggest Box (local)" href="http://www.visionmasterdesigns.com/2008/10/tutorial-auto-completer-using-prototype-scriptaculous/2/">Auto Suggest Box (local)</a></li>
<li>Page 3 : <a title="AJAX Auto Suggest Box (remote via PHP/MySQL)" href="http://www.visionmasterdesigns.com/2008/10/tutorial-auto-completer-using-prototype-scriptaculous/3/">AJAX Auto Suggest Box (remote via PHP/MySQL)</a></li>
</ul>
<h4>Demo &amp; Source Download</h4>
<p>Type out the name of the states of U.S.A.<br />
Local Auto Suggest Box Demo : <a href="http://www.visionmasterdesigns.com/demo/autocompleter/local.html" target="_blank">Click Here</a><br />
Remote Auto Suggest Box Demo : <a href="http://www.visionmasterdesigns.com/demo/autocompleter/ajax.html" target="_blank">Click Here</a></p>
<p>Download Source <a href="http://www.visionmasterdesigns.com/demo/autocompleter/autocompleter_src.rar">Here</a><br />
<span id="more-770"></span></p>
<h2>Problem Statement</h2>
<p>Lets try creating an Auto Suggest Box which displays the states of America as the user begins to type a state&#8217;s name in the text box.</p>
<h2>Solution</h2>
<p>Before using any functions, first we need to make our HTML page i.e how the suggestion box is going to look.</p>
<ol>
<li>Create an empty HTML file.</li>
<li>
    First, to take the input of any state name from the user we need an input box.<br />
    Second, we need a container to display all the probable suggestions i.e different names of states according to User input.</p>
<p>    Lets create these right now.</p>
<pre class="brush: html">
    &lt;!-- This code will be added inside the  &lt;strong&gt;&lt;BODY&gt;&lt;/strong&gt; tag of the HTML page --&gt;
    &lt;input type=&quot;text&quot; name=&quot;state_input&quot; id=&quot;state_input&quot; size=&quot;30&quot; /&gt;
    &lt;div id=&quot;state_suggestions&quot;&gt;&lt;!-- container for list of probable suggestions !--&gt;&lt;/div&gt;
    </pre>
</li>
<li>
    Now that we have designed our suggestion box, its time to implement the Auto Suggest Box method. Since this method is readily available as a part of Script.aculo.us, we need to include the scriptaculous file, and since scriptaculous depends on prototype, we need to include the prototype file to our HTML document. Type following code inside the <strong>&lt;HEAD&gt;</strong> tag.</p>
<pre class="brush: javascript">
	&lt;script src=&quot;js/lib/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;js/src/scriptaculous.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    </pre>
</li>
<li>
	The HTML page should look something like this.</p>
<pre class="brush: html">
    &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
    &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
    &lt;head&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
    &lt;title&gt;Untitled Document&lt;/title&gt;
    &lt;script src=&quot;js/lib/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script src=&quot;js/src/scriptaculous.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;input type=&quot;text&quot; name=&quot;state_input&quot; id=&quot;state_input&quot; size=&quot;30&quot; /&gt;
    &lt;div id=&quot;state_suggestions&quot;&gt;&lt;!-- container for list of probable suggestions !--&gt;&lt;/div&gt;

    &lt;/body&gt;
    &lt;/html&gt;
    </pre>
</li>
</ol>
<p>Now that we have a HTML page ready, preview it. Obviously it won&#8217;t work yet. We still have to define the AutoCompleter function.</p>
<p>There are 2 ways to achieve our goal. Script.aculo.us&#8217;s Autocompleter comes in two flavors.</p>
<ol>
<li><span class="code">Autocompleter.Local</span> : The local array autocompleter. Used when you’d prefer to inject an array of autocompletion options into the page, rather than sending out Ajax queries.</li>
<li><span class="code">Ajax.Autocompleter</span> : Which relies on a remote server to give it suggestions, making an AJAX Request whenever suggestions need to be retrieved.</li>
</ol>
<p>Now both have thier Pros and Cons. I`ll explain each one of them and how they can be used.</p>
]]></content:encoded>
			<wfw:commentRss>http://visionmasterdesigns.com/tutorial-auto-completer-using-prototype-scriptaculous/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Tutorial : Introduction to AJAX in Ruby on Rails with Prototype, Script.aculo.us</title>
		<link>http://visionmasterdesigns.com/tutorial-introduction-to-ajax-in-ruby-on-rails-with-prototype-scriptaculous/</link>
		<comments>http://visionmasterdesigns.com/tutorial-introduction-to-ajax-in-ruby-on-rails-with-prototype-scriptaculous/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 16:40:43 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript Frameworks]]></category>
		<category><![CDATA[Prototype, Script.aculo.us]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Script.aculo.us]]></category>

		<guid isPermaLink="false">http://www.visionmasterdesigns.com/?p=684</guid>
		<description><![CDATA[Heya, After a long time I had the time to update my blog. I have been working on my project presentation for the past 2 weeks. The entire presentation was developed in Flash CS3 coded in ActionScript 3. It was ages since I had used Flash and I was quite astonished how it had changed [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 0 0 0.6em 0.6em;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fvisionmasterdesigns.com%2Ftutorial-introduction-to-ajax-in-ruby-on-rails-with-prototype-scriptaculous%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fvisionmasterdesigns.com%2Ftutorial-introduction-to-ajax-in-ruby-on-rails-with-prototype-scriptaculous%2F&amp;source=rowoot&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Heya,<br />
After a long time I had the time to update my blog. I have been working on my project presentation for the past 2 weeks. The entire presentation was developed in Flash CS3 coded in ActionScript 3. It was ages since I had used Flash and I was quite astonished how it had changed over the years. I`ll be soon posting some tutorials on Flash, so do keep an eye out <img src='http://visionmasterdesigns.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Anyways apart from being a bit off-topic, This tutorial deals with AJAX implementation in Ruby on Rails 2. While I was learning RoR, I had lot of issues of properly having AJAX implementation in my projects. This tuorial is for those people out there.</p>
<p>In this tutorial, I`ll just show some very simple Script.aculo.us Animation Implementations in RoR.<br />
<a href="http://www.visionmasterdesigns.com:12001/ajaxfunction" target="_blank">View Demo</a></p>
<p><span id="more-684"></span></p>
<h2>Introduction</h2>
<p>First off, if you followed my RoR tutorials, you should know that RoR has AJAX support built in to it. It uses the Prototype Javascript Library along with Scriptaculous.</p>
<h2>Step 1 &#8211; Create new RoR Application</h2>
<p>First create a new RoR application. Edit the <span class="code">database.yml</span> file as well. If you are new to RoR, then visit <a href="http://www.visionmasterdesigns.com/2008/07/tutorial-developing-your-first-ruby-on-rails-2-application/">Tutorial : Developing your First Ruby on Rails 2 Application</a></p>
<h2>Step 2 &#8211; Create a Controller</h2>
<p>After creating the new application, we need to create a controller. lets call the controller <span class="code">ajaxfunctions</span>. I hope you guys know how to create a controller.</p>
<pre lang="ruby">    ruby script/generate controller ajaxfunctions index</pre>
<p>The above code will create a controller called <span class="code">ajaxfunctions</span> which will have a method called <span class="code">index</span>, respectively <span class="code">index.rhtml</span> OR <span class="code">index.html.erb</span> will be created inside the <strong>view/ajaxfunctions</strong> folder.</p>
<h2>Step 3 &#8211; Editing the view file</h2>
<p>Once you open it, you`ll notice that its empty. This is our template, basic HTML would suffice. So type out an html page here or you can use the one below.</p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Great. Now firstly, to implemenet AJAX in RoR , we need to initialize it.</p>
<h4>Initializing the Ajax code</h4>
<p>You must include the javascript code in your view template file (i.e index.rhtml in our case) for the Ajax functions to be available in that view. The best place for this is in the <span class="code">&lt;head&gt;</span> tag.</p>
<p>You can either use</p>
<ul>
<li><span class="code">&lt;%= javascript_include_tag  :defaults %&gt;</span><br />
We`ll be using this. Using this allows for quicker downloads since the script can be cached by the browsers.<br />
This is the output in the HTML page.</p>
<pre class="brush: html">
&lt;html&gt;
&lt;head&gt;
...
&lt;script src=&quot;/javascripts/prototype.js?1219423129&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/javascripts/effects.js?1219423129&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/javascripts/dragdrop.js?1219423129&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/javascripts/controls.js?1219423129&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/javascripts/application.js?1219423129&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
...
&lt;/head&gt;
&lt;/html&gt;
</pre>
</li>
<li><span class="code">&lt;%= define_javascript_functions %&gt;</span><br />
This pastes all of the required Javascript code right into your view which increases your page size by ~20KB.</li>
</ul>
<h4>Different AJAX Helpers used in View Files</h4>
<p>RoR creates the AJAX code for you via helper codes. Firstly</p>
<p><em>Defination:</em><br />
<strong>What is a Helper</strong> ?<br />
<strong>Helpers</strong> (“view helpers”) are modules that provide methods which are automatically usable in your view. They provide shortcuts to commonly used display code and a way for you to keep the programming out of your views. The purpose of a helper is to simplify the view. It’s best if the view file (RHTML/RXML) is short and sweet, so you can see the structure of the output. Nitty-gritty details are best left to helper methods and partials, where they can be parametrized and used repeatedly.</p>
<p><span class="code"><strong>Note :</strong> We can call AJAX via 2 methods i.e 1) Using a button and 2) Normal Links. Then we can add the arguments through which we can achieve to have cool visual effects or perform serious AJAX operations. </span></p>
<p><strong>AJAX</strong> Helpers</p>
<ol>
<li><span class="code"><strong>button_to_function(button_value, *args, &amp;mp;block)</strong></span><br />
Returns a button that‘ll trigger a JavaScript function using the onclick handler. All of these go into the body tag of the view file. You can use the <span class="code">visual_effect</span> function to specify any visual effects</p>
<p><strong>Example : </strong><br />
This will show a button with the value &#8220;Greeting&#8221;, upon clicking will show a alert box with &#8220;Hello World!&#8221; inside.</p>
<pre lang="ruby">&lt;%=button_to_function "Greeting", "alert('Hello world!')" %&gt;</pre>
<p>This will display a button with value &#8220;Fade&#8221;, upon clicking will fade in or fade out the element &#8216;fade_text&#8217; (It can be a div element with id=fade_text).</p>
<pre lang="ruby">&lt;%=button_to_function "Fade", visual_effect(:toggle_appear, "fade_text", :duration =&gt; 0.5)%&gt;</pre>
</li>
<li><span class="code"><strong>link_to_function(name, *args, &amp;block) </strong></span><br />
Intead of a button, if you want to implement AJAX functionality using a text link. You can use this helper.<br />
Returns a link that will trigger a JavaScript function using the onclick handler and return false after the fact.</p>
<p><strong>Example : </strong><br />
This will show a &#8220;Greeting&#8221; link, upon clicking will show a alert box with &#8220;Hello World!&#8221; inside.</p>
<pre lang="ruby">&lt;%=link_to_function "Greeting", "alert('Hello world!')" %&gt;</pre>
<p>This will display a &#8220;Slide Me&#8221; link, upon clicking it will slide in or out the element &#8216;slide_text&#8217; (It can be a div element with id=slide_text).</p>
<pre lang="ruby">&lt;%=link_to_function "Slide Me", visual_effect(:toggle_slide, "slide_text", :duration =&gt; 0.5)%&gt;</pre>
</li>
<h4>Helper for Animation</h4>
<li><span class="code">visual_effect(name, element_id = false, js_options = {})</span><br />
Returns a JavaScript snippet to be used on the Ajax callbacks for starting visual effects.</p>
<p><strong>Example : </strong><br />
This will show a &#8220;Highlight&#8221; button, upon clicking will highlight the element which is specified.</p>
<pre lang="ruby">&lt;%=button_to_function "Highlight", visual_effect(:highlight, "element_id_name",:startcolor =&gt; '#ffff99', :endcolor =&gt; '#ffffff')%&gt;</pre>
<p>This will display a &#8220;Grow&#8221; link, upon clicking it will grow the specified element_id_name</p>
<pre lang="ruby">&lt;%= link_to_function "Grow", visual_effect(:grow,"element_id_name",:direction =&gt; "center",:duration =&gt; 1)%&gt;</pre>
</li>
</ol>
<p>I would really suggest to go through <a href="http://github.com/madrobby/scriptaculous/wikis">Script.aculo.us WIKI</a> to know more about every effect and their parameters. All of these effects can be used with RoR. For Example I have attached the code for the demo file.</p>
<h2>Code for the Demo File</h2>
<p><a href="http://www.visionmasterdesigns.com:12001/ajaxfunction" target="_blank">View Demo</a></p>
<pre class="brush: ruby">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;AJAX&lt;/title&gt;
&lt;%= javascript_include_tag  :defaults %&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;%=button_to_function &quot;Greeting Alert Me&quot;, &quot;alert(&#039;Hello world!&#039;)&quot; %&gt;&lt;br /&gt;&lt;br /&gt;
&lt;h4&gt;Actions with paragraph using buttons&lt;/h4&gt;
&lt;%=button_to_function &quot;Fade&quot;, visual_effect(:toggle_appear, &quot;fade&quot;, :duration =&gt; 0.5)%&gt;
&lt;%=button_to_function &quot;Slide&quot;, visual_effect(:toggle_slide, &quot;fade&quot;,:duration =&gt; 1)%&gt;
&lt;%=button_to_function &quot;Highlight&quot;, visual_effect(:highlight, &quot;fade&quot;,:startcolor =&gt; &#039;#ffff99&#039;, :endcolor =&gt; &#039;#ffffff&#039;)%&gt;

&lt;div id=&quot;fade&quot; style=&quot;border:1px solid #dbdbdb; margin:50px;&quot;&gt;
This is test, This is test&lt;br&gt;
This is testing....&lt;br&gt;
Lorum ipsum blablasadadada
&lt;/div&gt;

&lt;h4&gt;Actions with Green Box using links&lt;/h4&gt;
&lt;%= link_to_function &quot;Toggle Fade&quot;, visual_effect(:toggle_appear, &quot;s1&quot;, :duration =&gt; 0.5)%&gt; ||
&lt;!-- Transitions --&gt;&lt;%= link_to_function &quot;Fade with wobble&quot;,&quot;new Effect.Fade(&#039;s1&#039;, { transition: Effect.Transitions.wobble })&quot; %&gt; ||
&lt;!-- grow effect --&gt;&lt;%= link_to_function &quot;Grow&quot;, visual_effect(:grow,&quot;s1&quot;,:direction =&gt; &quot;center&quot;,:duration =&gt; 1)%&gt; ||
&lt;!-- shake effect --&gt;&lt;%= link_to_function &quot;Shake&quot;, visual_effect(:shake,&quot;s1&quot;,:distance =&gt; &quot;30&quot;,:duration =&gt; 1)%&gt; ||
&lt;!-- morph effect --&gt;&lt;%= link_to_function &quot;Morph to Red box&quot;, visual_effect(:morph,&quot;s1&quot;,:style =&gt; &quot;{background: &#039;#f00&#039;,color: &#039;#fff&#039;,width: &#039;200px&#039;}&quot; )%&gt; ||
&lt;br&gt;
&lt;br&gt;
&lt;div id=&quot;s1&quot; style=&quot;width:80px; height:80px; cursor:move; background:#88da5d; border:1px solid #444; text-align:center;&quot;&gt;
&lt;/div&gt;

&lt;h4&gt;Drag Action with Blue Box&lt;/h4&gt;
&lt;div id=&quot;s2&quot; style=&quot;width:80px; height:80px; cursor:move; background:#7baaed; border:1px solid #333; text-align:center;&quot;&gt;
&lt;%= draggable_element(&quot;s2&quot;, :revert =&gt; true) %&gt;
DRAG ME
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h4>Related Articles</h4>
<p><a href="http://www.visionmasterdesigns.com/2008/07/tutorial-installing-ruby-on-rails-2-in-windows-vista-xp/">Tutorial : Installing Ruby on Rails 2 in Windows Vista/XP</a><br />
<a href="http://www.visionmasterdesigns.com/2008/07/tutorial-developing-your-first-ruby-on-rails-2-application/">Tutorial : Developing your First Ruby on Rails 2 Application</a><br />
<a href="http://www.visionmasterdesigns.com/2008/08/tutorial-basics-ruby-on-rails-2-model-controller-view-routing/">Tutorial : Basics on Ruby on Rails 2 Model, Controller and Views and Routing</a><br />
<a href="http://www.visionmasterdesigns.com/2008/08/tutorial-create-blog-using-ruby-on-rails-2-relationship/">Tutorial : Create a blog using Ruby on Rails 2. (Part 1 &#8211; Relationships)</a><br />
<a href="http://www.visionmasterdesigns.com/2008/09/tutorial-create-a-login-system-in-ruby-on-rails/">Tutorial : Create a login system in Ruby on Rails</a></p>
]]></content:encoded>
			<wfw:commentRss>http://visionmasterdesigns.com/tutorial-introduction-to-ajax-in-ruby-on-rails-with-prototype-scriptaculous/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
