<?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; Javascript Frameworks</title>
	<atom:link href="http://visionmasterdesigns.com/tag/javascript-frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://visionmasterdesigns.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 29 Oct 2009 20:00:15 +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>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>10</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>
		<item>
		<title>Tutorial : AJAX interface/menu using jQuery/PHP</title>
		<link>http://visionmasterdesigns.com/tutorial-ajax-interface-menu-using-jqueryphp/</link>
		<comments>http://visionmasterdesigns.com/tutorial-ajax-interface-menu-using-jqueryphp/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 15:24:34 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript Frameworks]]></category>
		<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.visionmasterdesigns.com/?p=218</guid>
		<description><![CDATA[Hello Guys, I have been busy with college lately, since this is my last year in college, I need to do a very cool project to get some good marks . Anyways that doesn`t mean I won`t be postin tutorials here . Want to present your data using AJAX/PHP/MySQL by just coding few lines ? [...]]]></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-ajax-interface-menu-using-jqueryphp%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fvisionmasterdesigns.com%2Ftutorial-ajax-interface-menu-using-jqueryphp%2F&amp;source=rowoot&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: center;"><a title="Ajax Interface" rel="lightbox[pics218]" href="http://www.visionmasterdesigns.com/blog/wp-content/uploads/2008/07/t1.jpg"><img class="attachment wp-att-219 centered" src="http://www.visionmasterdesigns.com/blog/wp-content/uploads/2008/07/t1.thumbnail.jpg" alt="Ajax Interface" width="350" height="180" /></a></p>
<p>Hello Guys,</p>
<p>I have been busy with college lately, since this is my last year in college, I need to do a very cool project to get some good marks <img src='http://visionmasterdesigns.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Anyways that doesn`t mean I won`t be postin tutorials here <img src='http://visionmasterdesigns.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Want to present your data using AJAX/PHP/MySQL by just coding few lines ? Well here it is. This tutorial teaches you how to present data using AJAX (using jQuery) with some neat effects. We can use PHP/MySQL to store the data and call it. In this tutorial I`ll teach you how to do so with PHP. So lets begin !</p>
<p>You can check the demo <a href="http://visionmasterdesigns.com/demo/ajaxinterface/" target="_blank">HERE</a>.<br />
You can download these files <a href="http://visionmasterdesigns.com/demo/ajaxinterface/interface.zip">HERE</a></p>
<h4>Index</h4>
<ol>
<li>Create the HTML page &#8211; <span class="code">index.html</span></li>
<li>
<ul>
<li><a href="http://www.visionmasterdesigns.com/2008/07/tutorial-ajax-interface-menu-using-jqueryphp/#css">The CSS</a></li>
<li><a href="http://www.visionmasterdesigns.com/2008/07/tutorial-ajax-interface-menu-using-jqueryphp/#html">The HTML</a></li>
<li><a href="http://www.visionmasterdesigns.com/2008/07/tutorial-ajax-interface-menu-using-jqueryphp/#javascript">The Javascript</a></li>
<li><a href="http://www.visionmasterdesigns.com/2008/07/tutorial-ajax-interface-menu-using-jqueryphp/#interface">Final interface.html page</a></li>
</ul>
</li>
<li>Create the PHP File &#8211; <span class="code">boo.php</span></li>
</ol>
<p><span id="more-218"></span></p>
<h2 align="center">HTML Page</h2>
<p>Our HTML file will contain the javascript as well as the CSS styles embedded within it. We can also create the effect by creating individual files for each i.e one for javascript functions and the other for the CSS. Anyways in this tutorial, both of them will be embedded within the html page. Now First fire up your favourite HTML editor (Personally I love Dreamweaver CS3).</p>
<p>We will be using The jQuery Framework &#8211; <span class="code">jquery.js</span>. If you want to know how the jQuery Framework works then do visit <a href="http://www.visionmasterdesigns.com/blog/2008/07/exploring-javascript-frameworks-jquery-126/">Exploring Javascript Frameworks : jQuery 1.2.6</a>.<br />
<!--adman--></p>
<h4><a name="css"></a>Step 1 &#8211; The CSS</h4>
<p>Lets add our css first. First create a new HTML file, call it <span class="code">interface.html</span>.<br />
The following is the css code.</p>
<pre class="brush: css">
&lt;style type=&quot;text/css&quot;&gt;
body { margin:0 auto 0 auto; color:#000; font-family:Georgia, &quot;Times New Roman&quot;, Times, serif; font-size:16px; background-color:#666666; }

.page { margin:100px auto 0 auto; width:750px;}

/*MENU START*/
#menu  { list-style:none; margin:0px; padding:0px;}

#menu li { list-style:none; display:inline; }
li.active a { background-color:#FFF;color:#000; }

#menu li a,#menu li a:link { float:left; background-color:#3c3c3c; margin-right:5px; padding:7px; color:#FFFFFF; text-decoration:none; width:6em; text-align:center;}
#menu li a:visited { }
#menu li a:hover { background-color:#327cc8 }
#menu li a:active { background-color:#FFF;color:#000; }
/* MENU END*/

#outcontent {clear:both; background-color:#FFFFFF; }
.content {background-color:#FFF; padding:10px; height:300px; margin:0px; }

#loading { clear:both; background:url(wait.gif) center top no-repeat; text-align:center;padding:33px 0px 0px 0px; font-size:12px;display:none; font-family:Verdana, Arial, Helvetica, sans-serif; }
&lt;/style&gt;
</pre>
<p>The CSS is pretty straight forward.</p>
<ul>
<li><span class="code">#page</span> will be assigned to a div, which will hold our menu and other divs
<li><span class="code">#menu</span> is the CSS to display our menu tabs.</li>
<li><span class="code">#loading</span> is the CSS to display the AJAX loading image.</li>
<li><span class="code">#outcontent</span> is the container to contain <span class="code">.content</span></li>
</ul>
<p>Put the above code inside the <span class="code">HEAD</span> tag of <span class="code">interface.html</span>. So <span class="code">interface.html</span> will look something like the following.</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;interface.html&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body { margin:0 auto 0 auto; color:#000; font-family:Georgia, &quot;Times New Roman&quot;, Times, serif; font-size:16px; background-color:#666666; }

.page { margin:100px auto 0 auto; width:750px;}

#menu  { list-style:none; margin:0px; padding:0px;}

#menu li { list-style:none; display:inline; }
li.active a { background-color:#FFF;color:#000; }

#menu li a,#menu li a:link { float:left; background-color:#3c3c3c; margin-right:5px; padding:7px; color:#FFFFFF; text-decoration:none; width:6em; text-align:center;}
#menu li a:visited { }
#menu li a:hover { background-color:#327cc8 }
#menu li a:active { background-color:#FFF;color:#000; }

.content {
background-color:#FFF; background:url(ajaxinterface.jpg) bottom right no-repeat; padding:10px; height:300px; margin:0px; }

#loading { clear:both; background:url(wait.gif) center top no-repeat; text-align:center;padding:33px 0px 0px 0px; font-size:12px;display:none; font-family:Verdana, Arial, Helvetica, sans-serif; }

#outcontent {clear:both; background-color:#FFFFFF; }

&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The above is the HTML page <span class="code">interface.html</span> with the CSS defined in it.</p>
<h4><a name="html"></a>Step 2 &#8211; The HTML</h4>
<p>Ok! Since now we have coded the CSS, lets create the HTML divs inside <span class="code">interface.html</span>.</p>
<ol>
<li>Inside the <span class="code">BODY</span> tag lets create a div which will contain the menu and the subsequent divs.</li>
<pre class="brush: html">
&lt;body&gt;
    &lt;div class=&quot;page&quot;&gt;
    &lt;!-- Menu and other divs go here !--&gt;
    &lt;/div&gt;
&lt;/body&gt;
</pre>
<li>Then we`ll create the menu Tabs.</li>
<pre class="brush: html">
&lt;body&gt;
    &lt;div class=&quot;page&quot;&gt;
    &lt;ul id=&quot;menu&quot;&gt;
    &lt;!-- you can add more tabs as you wish !--&gt;
             &lt;li id=&quot;about&quot;	&gt;&lt;a href=&quot;#&quot; title=&quot;about&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
            &lt;li id=&quot;portfolio&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;portfolio&quot;&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
            &lt;li id=&quot;contact&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;contact&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;br style=&quot;clear:both;&quot; /&gt;
    &lt;/div&gt;
&lt;/body&gt;
</pre>
<li>Now we need a container to display our <span class="code">Loading</span> text and our <span class="code">content</span>, so we`ll create 2 divs and lets put these divs inside another div called <span class="code">outcontent</span>. The following is how it`ll look.</li>
<pre class="brush: html">
&lt;body&gt;
    &lt;div class=&quot;page&quot;&gt;
        &lt;div&gt;
            &lt;ul id=&quot;menu&quot;&gt;
            &lt;!-- you can add more tabs as you wish !--&gt;
                         &lt;li id=&quot;about&quot;	&gt;&lt;a href=&quot;#&quot; title=&quot;about&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
                        &lt;li id=&quot;portfolio&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;portfolio&quot;&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
                        &lt;li id=&quot;contact&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;contact&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;br style=&quot;clear:both;&quot; /&gt;
        &lt;/div&gt;
        &lt;!-- #outcontent - Overall div containing Loading div &amp;amp;amp; content div !--&gt;
        &lt;div id=&quot;outcontent&quot;&gt;
           	 &lt;div id=&quot;loading&quot;&gt;LOADING&lt;/div&gt;
            &lt;div class=&quot;content&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;!-- #outcontent end !--&gt;
    &lt;/div&gt;
&lt;/body&gt;
</pre>
</ol>
<p><span class="code">interface.html</span></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;interface.html&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body { margin:0 auto 0 auto; color:#000; font-family:Georgia, &quot;Times New Roman&quot;, Times, serif; font-size:16px; background-color:#666666; }

.page { margin:100px auto 0 auto; width:750px;}

#menu  { list-style:none; margin:0px; padding:0px;}

#menu li { list-style:none; display:inline; }
li.active a { background-color:#FFF;color:#000; }

#menu li a,#menu li a:link { float:left; background-color:#3c3c3c; margin-right:5px; padding:7px; color:#FFFFFF; text-decoration:none; width:6em; text-align:center;}
#menu li a:visited { }
#menu li a:hover { background-color:#327cc8 }
#menu li a:active { background-color:#FFF;color:#000; }

.content {
background-color:#FFF; padding:10px; height:300px; margin:0px; }

#loading { clear:both; background:url(wait.gif) center top no-repeat; text-align:center;padding:33px 0px 0px 0px; font-size:12px;display:none; font-family:Verdana, Arial, Helvetica, sans-serif; }

#outcontent {clear:both; background-color:#FFFFFF; }

&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div class=&quot;page&quot;&gt;
&lt;div&gt;
&lt;ul id=&quot;menu&quot;&gt;
             &lt;li id=&quot;about&quot;	&gt;&lt;a href=&quot;#&quot; title=&quot;about&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
            &lt;li id=&quot;portfolio&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;portfolio&quot;&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
            &lt;li id=&quot;contact&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;contact&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br style=&quot;clear:both;&quot; /&gt;
&lt;/div&gt;
&lt;div id=&quot;outcontent&quot;&gt;
&lt;div id=&quot;loading&quot;&gt;LOADING&lt;/div&gt;
&lt;div class=&quot;content&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The page should look something like the following</p>
<p style="text-align: center;"><a href="http://www.visionmasterdesigns.com/blog/wp-content/uploads/2008/07/t2.jpg" rel="lightbox[pics218]" title="empty Interface.html"><img src="http://www.visionmasterdesigns.com/blog/wp-content/uploads/2008/07/t2.thumbnail.jpg" alt="empty Interface.html" width="425" height="305" class="attachment wp-att-229 centered" /></a></p>
<h4><a name="javascript"></a>Step 3 &#8211; Add the Javascript Magic !</h4>
<p>This page would do for static pages, but we are making an AJAX powered page ! Its time to add the magic.<br />
First if you have read the <a href="http://www.visionmasterdesigns.com/blog/2008/07/exploring-javascript-frameworks-jquery-126/">Exploring Javascript Frameworks : jQuery 1.2.6</a> post, it should not be a problem.</p>
<ol>
<li>First lets link to the jquery library</li>
<pre class="brush: javascript">
&lt;script src=&quot;jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<li>Next lets open the script tag again and add the following code. The following code is pretty explainatory. I have added a lot of comments to show what each and every line does.</li>
<pre class="brush: javascript">
&lt;script&gt;
  // When the document loads do everything inside here ...
     $(document).ready(function(){
	 $(&#039;.content&#039;).load(&#039;boo.php&#039;);	//by default initally load text from boo.php
         $(&#039;#menu a&#039;).click(function() { //start function when any link is clicked
		 				$(&quot;.content&quot;).slideUp(&quot;slow&quot;);
						 var content_show = $(this).attr(&quot;title&quot;); //retrieve title of link so we can compare with php file
							$.ajax({
							method: &quot;get&quot;,url: &quot;boo.php&quot;,data: &quot;page=&quot;+content_show,
							beforeSend: function(){$(&quot;#loading&quot;).show(&quot;fast&quot;);}, //show loading just when link is clicked
							complete: function(){ $(&quot;#loading&quot;).hide(&quot;fast&quot;);}, //stop showing loading when the process is complete
							success: function(html){ //so, if data is retrieved, store it in html
							$(&quot;.content&quot;).show(&quot;slow&quot;); //animation
							$(&quot;.content&quot;).html(html); //show the html inside .content div
					 }
				 }); //close $.ajax(
         }); //close click(
	 }); //close $(
&lt;/script&gt;
</pre>
</ol>
<p>Voila ! thats it.</p>
<h2><a name="interface"></a>Our Final interface.html page</h2>
<pre class="brush: javascript">
&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;interface.html&lt;/title&gt;
&lt;script src=&quot;jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
 &lt;script&gt;
  // When the document loads do everything inside here ...
     $(document).ready(function(){
	 $(&#039;.content&#039;).load(&#039;boo.php&#039;);	//by default initally load text from boo.php
         $(&#039;#menu a&#039;).click(function() { //start function when any link is clicked
		 				$(&quot;.content&quot;).slideUp(&quot;slow&quot;);
						 var content_show = $(this).attr(&quot;title&quot;); //retrieve title of link so we can compare with php file
							$.ajax({
							method: &quot;get&quot;,url: &quot;boo.php&quot;,data: &quot;page=&quot;+content_show,
							beforeSend: function(){$(&quot;#loading&quot;).show(&quot;fast&quot;);}, //show loading just when link is clicked
							complete: function(){ $(&quot;#loading&quot;).hide(&quot;fast&quot;);}, //stop showing loading when the process is complete
							success: function(html){ //so, if data is retrieved, store it in html
							$(&quot;.content&quot;).show(&quot;slow&quot;); //animation
							$(&quot;.content&quot;).html(html); //show the html inside .content div
					 }
				 }); //close $.ajax(
         }); //close click(
	 }); //close $(
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
body { margin:0 auto 0 auto; color:#000; font-family:Georgia, &quot;Times New Roman&quot;, Times, serif; font-size:16px; background-color:#666666; }

.page { margin:100px auto 0 auto; width:750px;}

#menu  { list-style:none; margin:0px; padding:0px;}

#menu li { list-style:none; display:inline; }
li.active a { background-color:#FFF;color:#000; }

#menu li a,#menu li a:link { float:left; background-color:#3c3c3c; margin-right:5px; padding:7px; color:#FFFFFF; text-decoration:none; width:6em; text-align:center;}
#menu li a:visited { }
#menu li a:hover { background-color:#327cc8 }
#menu li a:active { background-color:#FFF;color:#000; }

.content {
background-color:#FFF; padding:10px; height:300px; margin:0px; }

#loading { clear:both; background:url(wait.gif) center top no-repeat; text-align:center;padding:33px 0px 0px 0px; font-size:12px;display:none; font-family:Verdana, Arial, Helvetica, sans-serif; }

#outcontent {clear:both; background-color:#FFFFFF; }

&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div class=&quot;page&quot;&gt;
&lt;div&gt;
&lt;ul id=&quot;menu&quot;&gt;
             &lt;li id=&quot;about&quot;	&gt;&lt;a href=&quot;#&quot; title=&quot;about&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
            &lt;li id=&quot;portfolio&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;portfolio&quot;&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
            &lt;li id=&quot;contact&quot;&gt;&lt;a href=&quot;#&quot; title=&quot;contact&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br style=&quot;clear:both;&quot; /&gt;
&lt;/div&gt;
&lt;div id=&quot;outcontent&quot;&gt;
&lt;div id=&quot;loading&quot;&gt;LOADING&lt;/div&gt;
&lt;div class=&quot;content&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://visionmasterdesigns.com/tutorial-ajax-interface-menu-using-jqueryphp/feed/</wfw:commentRss>
		<slash:comments>89</slash:comments>
		</item>
		<item>
		<title>Exploring Javascript Frameworks : jQuery 1.2.6</title>
		<link>http://visionmasterdesigns.com/exploring-javascript-frameworks-jquery-126/</link>
		<comments>http://visionmasterdesigns.com/exploring-javascript-frameworks-jquery-126/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 14:03:28 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript Frameworks]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://blog.visionmasterdesigns.com/?p=134</guid>
		<description><![CDATA[Always found Javascript boring, its time you start checking out the greener side of Javascript. This Article explores the Javascript Framework : jQuery.]]></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%2Fexploring-javascript-frameworks-jquery-126%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fvisionmasterdesigns.com%2Fexploring-javascript-frameworks-jquery-126%2F&amp;source=rowoot&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Hey guys,</p>
<p>You might be wondering where the hell are the Rails Tuts ! But before that, some of you might have read the <a href="http://www.visionmasterdesigns.com/blog/2008/07/tutorial-introduction-ajax-with-php/">Tutorial : Introduction to AJAX with PHP</a>, if you think coding AJAX is tough, think again ! Recently I have been doing a lot of research about different javascript frameworks which will help me ease AJAX and I came across <strong>JQuery</strong> and <strong>Prototype</strong>. It seems they were very commonly used by lot of people. Not only that, these frameworks, besides just providing AJAX they have a lot of cool features. So I decided to explore them.</p>
<p>This post explores some neat tricks I could do using jQuery ! So read on guys if you wanna learn <img src='http://visionmasterdesigns.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>Index</h2>
<ul>
<li>Introduction</li>
<li><a href="http://www.visionmasterdesigns.com/blog/2008/07/exploring-javascript-frameworks-jquery-126/#jwhat">What is jQuery ?</a></li>
<li><a href="http://www.visionmasterdesigns.com/blog/2008/07/exploring-javascript-frameworks-jquery-126/#download">Download jQuery ?!</a></li>
<li><a href="http://www.visionmasterdesigns.com/blog/2008/07/exploring-javascript-frameworks-jquery-126/#play">Playing with jQuery ?!</a></li>
<li><a href="http://www.visionmasterdesigns.com/blog/2008/07/exploring-javascript-frameworks-jquery-126/#effects">jQuery Effects ! ?</a></li>
</ul>
<p><span id="more-134"></span><br />
<a name="what"></a></p>
<h2>What is jQuery ?</h2>
<p>Ok ! If you have read <a href="http://www.visionmasterdesigns.com/blog/2008/07/tutorial-introduction-ajax-with-php/">Tutorial : Introduction to AJAX with PHP</a>, you will notice what a pain it is to code using javascript. Imagine the same same function to be performed by writing just 5 lines&#8230;this is what jQuery can help us achieve.</p>
<p>It is a set of functions written in javascript, to make our life easier.<br />
For Example</p>
<pre class="brush: javascript">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Base page for content&lt;/title&gt;
&lt;script src=&quot;jquery-1.2.6.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
jQuery(function($) {
$(&quot;#contentArea&quot;).load(&quot;a.html&quot;);
});

//--&gt;
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;contentArea&quot;&gt;&lt;!--loads contents of a.html here--&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The above javascript function will load the contents of a.html to our div with id=contentArea. Imagine doing the same with normal AJAX functions, it would take anything not less than 10 lines of code. Anyways lets see how can use jQuery to minimize our load.</p>
<p><a name="download"></a></p>
<h2>Download jQuery</h2>
<p>First lets download the javascript framework from <a href="http://jquery.com">jquery.com</a>. Since we plan to develop and do a lot testing, download the <a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.js">jQuery 1.2.6 (97kb, Uncompressed)</a>.</p>
<p>Download the jquery-1.2.6.js file and save it.</p>
<p>Everytime we want to use jQuery, we need to include the above script in our HTML files. You can do so as shown below i.e add <span class="code"><script src="jquery-1.2.6.js" type="text/javascript"></script></span> between the head tags.</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;jquery-1.2.6.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
 &lt;/head&gt;
 &lt;body&gt;
 &lt;/body&gt;
 &lt;/html&gt;
 </pre>
<p><a name="play"></a></p>
<h2>Playing with jQuery ?!</h2>
<p>Like I showed you in Page 2. 3 lines of code in javascript using jQuery can do stuff which is far more than 10 lines of code in javascript without jQuery.<br />
 Anyways I am going to show you some neat tricks you can do using jQuery. The basics ofcourse !</p>
<h4>The basic code</h4>
<p>Like I said, you need to include the basic javascript library file if you want to use jQuery features.</p>
<h4>ready function</h4>
<p>The following code shows jQuery equivalent code to the javascript function</p>
<pre class="brush: javascript">
 // normal javascript
 &lt;script type=&quot;text/javascript&quot;&gt;
 window.onload = function(){ alert(&quot;abc&quot;); }
 &lt;/script&gt;

// equivalent in jQuery
 &lt;script src=&quot;jquery-1.2.6.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
 $(document).ready(function(){ alert(&quot;abc&quot;); });
 &lt;/script&gt;
 </pre>
<p> <strong>What it does : </strong><br />
 Both the code alert the user with a message box, having msg &#8220;abc&#8221;.</p>
<h4>click function</h4>
<pre class="brush: javascript">
 &lt;script type=&quot;text/javascript&quot;&gt;
 // normal javascript
 function clickme() {
 alert(&quot;abc&quot;);
 }
 &lt;/script&gt;
 &lt;a href=&quot;#&quot; onClick=&quot;clickme();&quot;&gt;Have to specify the function for links you want alert to show&lt;/a&gt;

&lt;script src=&quot;jquery-1.2.6.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
 $(document).ready(function() {
 $(&quot;a&quot;).click(function () {	// When any link is clicked
 alert(&quot;abc&quot;); //alert user
 });
 });
 &lt;/script&gt;
 &lt;a href=&quot;#&quot;&gt;All the links will alert&lt;/a&gt;
 </pre>
<p> <strong>What it does : </strong></p>
<p><strong>Normal Javascript -</strong>Displays alert box, if a links is clicked. In normal javascript, we have to write a call to the clickme() function on every link to show alert box.<br />
 <strong>jQuery &#8211; </strong>All the links will show alert box on click since<br />
 <span class="code">$(&#8220;a&#8221;).click(function () {//function });</span> where &#8220;a&#8221; refers to all anchor tags.<br />
 If you want to specify any one particular tag, then<br />
 <span class="code">$(&#8220;a#1&#8243;).click(function () {//function });</span> where alert box will only be displayed when a link with id=1 is clicked.</p>
<h4>add class</h4>
<p><span class="code">$(&#8220;div#foo&#8221;).addClass(&#8220;test&#8221;);</span><br />
 The above code will add the class test to div with id=foo. You can add css styles using this piece of code.</p>
<h4>html code</h4>
<p><span class="code">$(&#8220;div#foo&#8221;).html(&#8220;Hello World&#8221;);</span><br />
 The above code, will update div with id=foo, with Hello World. This is more like<br />
 <span class="code">obj.innerHTML = &#8220;Hello World&#8221;</span> where<br />
 <span class="code">obj = document.getElement(&#8220;foo&#8221;);</span>.</p>
<p>For more information, I suggest you read this <a href="http://docs.jquery.com/Frequently_Asked_Questions">Frequently Asked Questions</a>.</p>
<p>Now lets move to the next page and create some effects !!</p>
<p><a name="effects"></a></p>
<h2>jQuery Effects ! ?</h2>
<p>Yup thats right, jQuery has some neat effects up its sleave.<br />
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script><br />
<script type="text/javascript"><!--
$(document).ready(function() {	
		//fade functions
		$("#fadein").click(function () {	// When any link is clicked		
		$("#fadeeffect").fadeIn("slow");
		});	
		$("#fadeout").click(function () {	// When any link is clicked		
		$("#fadeeffect").fadeOut("slow");
		});
		//slide functions
		$("#slidein").click(function () {	// When any link is clicked		
		$("#slideeffect").slideDown("slow");
		});	
		$("#slideout").click(function () {	// When any link is clicked		
		$("#slideeffect").slideUp("slow");
		});
		//custom animation
		$("#custom").click(function(){
    	$("#customtext").animate({ 
        width: "70%",
        opacity: 0.5,
        marginLeft: "0.6in",
        fontSize: "2em" 
        }, 1500 );
    });
	  });
// --></script></p>
<input id="fadein" name="fadein" type="button" value="Fade In" />
<input id="fadeout" name="fadeout" type="button" value="Fade Out" />
<div id="fadeeffect" style="border:1px solid #1a6780; display:none; margin:10px; background-color:#e3eff3;padding:10px;">FADING&#8230;<br />
Lorem epsom sied van heity rath mapark to ratham. Msgyht raspiem maks vem iey tor sto fo rtem leom. Marks maxi umlion tor pion skim quedrtem lorespiortium.</div>
<input id="slidein" name="slidein" type="button" value="Slide In" />
<input id="slideout" name="slideout" type="button" value="Slide Out" />
<div id="slideeffect" style="border:1px solid #1a6780; display:none; margin:10px; background-color:#e3eff3;padding:10px;">SLIDING&#8230;<br />
Lorem epsom sied van heity rath mapark to ratham. Msgyht raspiem maks vem iey tor sto fo rtem leom. Marks maxi umlion tor pion skim quedrtem lorespiortium.</div>
<p>The code for the above effects..</p>
<pre class="brush: javascript">
&lt;script src=&quot;http://code.jquery.com/jquery-latest.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
//fade functions
$(&quot;#fadein&quot;).click(function () {	// When any link is clicked
$(&quot;#fadeeffect&quot;).fadeIn(&quot;slow&quot;); //fade in effect
});
$(&quot;#fadeout&quot;).click(function () {	// When any link is clicked
$(&quot;#fadeeffect&quot;).fadeOut(&quot;slow&quot;); //fade out effect
});
//slide functions
$(&quot;#slidein&quot;).click(function () {	// When any link is clicked
$(&quot;#slideeffect&quot;).slideDown(&quot;slow&quot;); //slide in
});
$(&quot;#slideout&quot;).click(function () {	// When any link is clicked
$(&quot;#slideeffect&quot;).slideUp(&quot;slow&quot;); //slide out
});
});
&lt;/script&gt;
&lt;input type=&quot;button&quot; id=&quot;fadein&quot; name=&quot;fadein&quot; value=&quot;Fade In&quot; /&gt;
&lt;input type=&quot;button&quot; id=&quot;fadeout&quot; name=&quot;fadeout&quot; value=&quot;Fade Out&quot; /&gt;
&lt;div id=&quot;fadeeffect&quot; style=&quot;border:1px solid #1a6780; display:none; margin:10px;padding:10px; background-color:#e3eff3;&quot;&gt;
FADING...
Lorem epsom sied van heity rath mapark to ratham. Msgyht raspiem maks vem iey tor sto fo rtem leom. Marks maxi umlion tor pion skim quedrtem lorespiortium.
&lt;/div&gt;
&lt;input type=&quot;button&quot; id=&quot;slidein&quot; name=&quot;slidein&quot; value=&quot;Slide In&quot;  /&gt;
&lt;input type=&quot;button&quot; id=&quot;slideout&quot; name=&quot;slideout&quot; value=&quot;Slide Out&quot;  /&gt;
&lt;div id=&quot;slideeffect&quot; style=&quot;border:1px solid #1a6780; display:none; margin:10px; padding:10px; background-color:#e3eff3;&quot;&gt;
SLIDING...
Lorem epsom sied van heity rath mapark to ratham. Msgyht raspiem maks vem iey tor sto fo rtem leom. Marks maxi umlion tor pion skim quedrtem lorespiortium.
&lt;/div&gt;
</pre>
<p>Pretty cool huh ! just 3 lines of code and viola !<br />
jQuery also gives the ability to create a custom animation.</p>
<input id="custom" name="custom" type="button" value="Animate" />
<div id="customtext" style="border: 1px solid #1a6780; margin: 10px; padding: 5px; background-color: #e3eff3; width: 100px;">Animate</div>
<p>The code for the above is</p>
<pre class="brush: javascript">
&lt;script src=&quot;http://code.jquery.com/jquery-latest.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
//custom animation
$(&quot;#custom&quot;).click(function(){
$(&quot;#customtext&quot;).animate({
width: &quot;70%&quot;,
opacity: 0.5,
marginLeft: &quot;0.6in&quot;,
fontSize: &quot;2em&quot;,
}, 1500 );
});
&lt;/script&gt;
&lt;input type=&quot;button&quot; id=&quot;custom&quot; name=&quot;custom&quot; value=&quot;Animate&quot;  /&gt;
&lt;div id=&quot;customtext&quot; style=&quot;border:1px solid #1a6780; margin:10px; padding:5px; background-color:#e3eff3; width:100px;&quot;&gt;
Animate ME !
&lt;/div&gt;
</pre>
<p>You can read more documentation about these effects <a href="http://docs.jquery.com/Effects">http://docs.jquery.com/Effects</a>.</p>
<p>Well I have covered most of the usual functions people use with jQuery. Use your imagination to create stunning webpages. you can visit <a href="http://www.visionmasterdesigns.com">http://www.visionmasterdesigns.com</a> since it is jQuery powered.</p>
<p>But hold on guys ! Be sure to check out the next part where we will be exploring another famous javascript framework &#8220;<a href="http://www.prototypejs.org">Prototype</a>&#8220;.</p>
<p>Cya</p>
<div class="donate"><strong>Found this tutorial really useful, you can click here to donate.</strong></p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_donations" />
<input name="business" type="hidden" value="rowoot@gmail.com" />
<input name="item_name" type="hidden" value="MICHEAL BENEDICT ARUL" />
<input name="no_shipping" type="hidden" value="0" />
<input name="no_note" type="hidden" value="1" />
<input name="currency_code" type="hidden" value="USD" />
<input name="tax" type="hidden" value="0" />
<input name="lc" type="hidden" value="IN" />
<input name="bn" type="hidden" value="PP-DonationsBF" />
<input alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" type="image" /> <img src="https://www.paypal.com/en_US/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /><br />
</form>
</div>
]]></content:encoded>
			<wfw:commentRss>http://visionmasterdesigns.com/exploring-javascript-frameworks-jquery-126/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
