<?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>David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞. &#187; jQuery</title> <atom:link href="http://davidwalsh.name/tutorials/jquery/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 02 Sep 2010 03:13: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>Duplicate the jQuery Homepage&#160;Tooltips</title><link>http://davidwalsh.name/jquery-tooltips</link> <comments>http://davidwalsh.name/jquery-tooltips#comments</comments> <pubDate>Tue, 31 Aug 2010 13:48:40 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5056</guid> <description><![CDATA[The jQuery homepage has a pretty suave tooltip-like effect as seen below: The amount of jQuery required to duplicate this effect is next to nothing;  in fact, there&#8217;s more CSS than there is jQuery code!  Let&#8217;s explore how we can duplicate jQuery&#8217;s tooltip effect. View Demo The&#160;HTML The overall structure includes a wrapping DIV element [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-tooltips">Duplicate the jQuery Homepage&nbsp;Tooltips</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/jquery-homepage-mootools' rel='bookmark' title='Permanent Link: Duplicate the jQuery Homepage Tooltips Using&nbsp;MooTools'>Duplicate the jQuery Homepage Tooltips Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/dojo-tooltips' rel='bookmark' title='Permanent Link: Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo'>Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/mootools-12-tooltips-customize' rel='bookmark' title='Permanent Link: MooTools 1.2 Tooltips: Customize Your&nbsp;Tips'>MooTools 1.2 Tooltips: Customize Your&nbsp;Tips</a></li><li><a
href='http://davidwalsh.name/album-art' rel='bookmark' title='Permanent Link: Sexy Album Art with MooTools or&nbsp;jQuery'>Sexy Album Art with MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/mootools-jquery-textbox-list' rel='bookmark' title='Permanent Link: TextboxList for MooTools and jQuery by Guillermo&nbsp;Rauch'>TextboxList for MooTools and jQuery by Guillermo&nbsp;Rauch</a></li></ol>]]></description> <content:encoded><![CDATA[<p>The jQuery homepage has a pretty suave tooltip-like effect as seen below:</p><p><a
href="http://davidwalsh.name/dw-content/jquery-tooltips-jquery.php"><img
src="http://davidwalsh.name/dw-content/jquery-home.png" alt="jQuery Tooltips" /></a></p><p>The amount of jQuery required to duplicate this effect is next to nothing;  in fact, there&#8217;s more CSS than there is jQuery code!  Let&#8217;s explore how we can duplicate jQuery&#8217;s tooltip effect.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/jquery-tooltips-jquery.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;HTML</h2><p>The overall structure includes a wrapping DIV element with each tooltip link featured in a list:</p><pre class="html">
&lt;div id="jq-intro" class="jq-clearfix"&gt;
	&lt;h2&gt;jQuery is a new kind of JavaScript Library.&lt;/h2&gt;
	&lt;p&gt;jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and AJAX interactions for rapid web development. &lt;strong&gt;jQuery is designed to change the way that you write JavaScript.&lt;/strong&gt;&lt;/p&gt;
	&lt;ul class="jq-checkpoints jq-clearfix"&gt;
		&lt;li&gt;&lt;a href="http://docs.jquery.com/Tutorials" title="Lightweight Footprint" class="jq-thickbox"&gt;Lightweight Footprint&lt;/a&gt;
			&lt;div class="jq-checkpointSubhead"&gt;
				&lt;p&gt;About 18KB in size &lt;em&gt;(Minified and Gzipped)&lt;/em&gt;&lt;/p&gt;
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://docs.jquery.com/Tutorials" title="CSS3 Compliant" class="jq-thickbox"&gt;CSS3 Compliant&lt;/a&gt;
			&lt;div class="jq-checkpointSubhead"&gt;
				&lt;p&gt;Supports CSS 1-3 selectors and more!&lt;/p&gt;
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://docs.jquery.com/Tutorials" title="Cross-browser" class="jq-thickbox"&gt;Cross-browser&lt;/a&gt;
			&lt;div class="jq-checkpointSubhead"&gt;
				&lt;p&gt;IE 6.0+, FF 2+, Safari 3.0+, Opera 9.0+, Chrome&lt;/p&gt;
			&lt;/div&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre><p>Note that the UL element has been given a jq-checkpoints CSS class &#8212; we&#8217;ll use that in a selector for both CSS styling and element collection using jQuery.</p><h2>The&nbsp;CSS</h2><p>Like I said&#8230;there&#8217;s more CSS than there will be jQuery code:</p><pre class="css">
#jq-intro 			{ padding-top:1em; width:605px; margin:0 auto; }
#jq-intro h2 		{ font-size:1.9em; font-weight:bold; color:#5DB0E6; line-height:1em; }
#jq-intro h2 span.jq-jquery { float:left; width:81px; height:23px; margin-right:.3em; position:relative; }
#jq-intro h2 span.jq-jquery span { position:absolute; left:-999999px; }
#jq-intro p 		{ clear:both; font-size:1.5em; margin:5px 0; font-weight:normal; line-height:1.6; }
#jq-intro ul 		{ padding:1.5em 0; list-style-type:none; }
#jq-intro li 		{ float:left; font-size:1.4em; }
#jq-intro li a 	{ color:#5DB0E6; font-weight:bold; text-decoration:underline; float:left; padding:0 30px 0 23px; }
#jq-intro li p 	{ font-size:12px; }
#jq-intro li 		{ position:relative; }
div.jq-checkpointSubhead { display:none; position:absolute; width:253px; height:54px; background:url(jquery-tooltip.png) 0 0 no-repeat; top:-1.5em; left:-35%; z-index:100; }
div.jq-checkpointSubhead p { font-size:1em; padding:10px 5px 0 50px; color:#AE0001; font-weight:bold; line-height:1.3em; margin:0; cursor:pointer; }
</pre><p>Most of the CSS is gloss for the overall look.  The important piece is the jq-checkpointSubhead CSS class being positioned absolutely and with an initial display value of none.  That will allow us to use the :hidden selector within jQuery.</p><h2>The jQuery&nbsp;JavaScript</h2><p>And now for the jQuery JavaScript:</p><pre class="js">
jQuery(document).ready(function() {
	var duration = 500;
	jQuery('.jq-checkpoints li').hover(
		function(){ jQuery(this).find('div.jq-checkpointSubhead:hidden').fadeIn(duration); },
		function(){ jQuery(this).find('div.jq-checkpointSubhead:visible').fadeOut(duration); }
	);
});
</pre><p>When the use hovers over the list items, the tooltip for the given list item fades in.  When the user leaves the list item, the tooltip fades out.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/jquery-tooltips-jquery.php" class="demo">View Demo</a><div
class="clear"></div></div><p>There you have it.  If you&#8217;re interested in how to do this with out JavaScript frameworks, read my <a
href="http://davidwalsh.name/jquery-homepage-mootools">MooTools</a> and <a
href="http://davidwalsh.name/dojo-tooltips">Dojo</a> tutorials!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-tooltips">Duplicate the jQuery Homepage&nbsp;Tooltips</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/jquery-homepage-mootools' rel='bookmark' title='Permanent Link: Duplicate the jQuery Homepage Tooltips Using&nbsp;MooTools'>Duplicate the jQuery Homepage Tooltips Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/dojo-tooltips' rel='bookmark' title='Permanent Link: Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo'>Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/mootools-12-tooltips-customize' rel='bookmark' title='Permanent Link: MooTools 1.2 Tooltips: Customize Your&nbsp;Tips'>MooTools 1.2 Tooltips: Customize Your&nbsp;Tips</a></li><li><a
href='http://davidwalsh.name/album-art' rel='bookmark' title='Permanent Link: Sexy Album Art with MooTools or&nbsp;jQuery'>Sexy Album Art with MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/mootools-jquery-textbox-list' rel='bookmark' title='Permanent Link: TextboxList for MooTools and jQuery by Guillermo&nbsp;Rauch'>TextboxList for MooTools and jQuery by Guillermo&nbsp;Rauch</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/jquery-tooltips/feed</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Create a Twitter AJAX Button with MooTools, jQuery, or&#160;Dojo</title><link>http://davidwalsh.name/twitter-button</link> <comments>http://davidwalsh.name/twitter-button#comments</comments> <pubDate>Wed, 25 Aug 2010 03:28:19 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Dojo]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5049</guid> <description><![CDATA[There&#8217;s nothing like a subtle, slick website widget that effectively uses CSS and JavaScript to enhance the user experience.  Of course widgets like that take many hours to perfect, but it doesn&#8217;t take long for that effort to be rewarded with above-average user retention and buzz.  One of the widgets I love is Twitter&#8217;s &#8220;Follow&#8221; [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/twitter-button">Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/dojo-ajax' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;Dojo'>Animated AJAX Record Deletion Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/animated-button' rel='bookmark' title='Permanent Link: Create an Animated Sliding Button Using&nbsp;MooTools'>Create an Animated Sliding Button Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;jQuery'>Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://davidwalsh.name/dw-content/twitter-follow.php"><img
src="http://davidwalsh.name/dw-content/twitter-button.jpg" alt="Twitter Button" class="image" /></a><p>There&#8217;s nothing like a subtle, slick website widget that effectively uses CSS and JavaScript to enhance the user experience.  Of course widgets like that take many hours to perfect, but it doesn&#8217;t take long for that effort to be rewarded with above-average user retention and buzz.  One of the widgets I love is Twitter&#8217;s &#8220;Follow&#8221; button.  Let me show you how you can implement this functionality with three popular JavaScript toolkits:  MooTools, jQuery, and Dojo.</p><p><em>Note:  This tutorial will only display the client side handling of the form submission &#8212; NOT any PHP/MySQL/server-side handling of the request.</em></p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php" class="demo">View MooTools Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=dojo" class="demo">View Dojo Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=jquery" class="demo">View jQuery Demo</a><div
class="clear"></div></div><h2>The HTML&nbsp;Structure</h2><pre class="html">
<form class="follow-form" method="post" action="twitter-follow.php">
	<input type="hidden" name="followID" value="123456" />
	<button type="submit" value="Actions" class="btn follow" title="123456">
		<i></i><span>follow</span>
	</button>
</form>
</pre><p>The HTML for the button is very simple.  The structure revolves around a BUTTON element which contains an I element and SPAN element.  You&#8217;re probably thinking &#8220;An I element?  WTF.&#8221;  I know I did.  The truth of the matter is that the I element is deprecated and, as far as I&#8217;m concerned, and be used for any purpose the developer would like.  I&#8217;m also sure that Twitter doesn&#8217;t mind saving bytes here or there.</p><h2>The CSS&nbsp;Styles</h2><pre class="css">
/* twitter button and its children */
button.btn { 
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
	background-attachment:scroll;
	background-color:#ddd;
	background-image:url(http://s.twimg.com/a/1282150308/images/buttons/bg-btn.gif);
	background-position:0 0;
	background-repeat:repeat-x;
	border:1px solid #ddd;
	border-bottom:1px solid #ccc;
	color:#333;
	cursor:pointer;
	font-family:"Lucida Grande",sans-serif;
	font-size:11px;
	line-height:14px;
	padding:4px 8px 5px 8px;
	text-shadow:1px 1px 0 #fff;
	vertical-align:top;
}
button.btn:hover {
	border:1px solid #999;
	border-bottom-color:#888;
	color:#000;
	background-color:#d5d5d5;
	background-position:0 -6px;
}
button.btn:active {
	background-image:none !important;
	text-shadow:none !important;
}
			
button.btn i {
	background-image:url(http://s.twimg.com/a/1282150308/images/sprite-icons.png);
	background-position:-176px -32px;
	background-repeat:no-repeat;
	display:inline-block;
	height:13px;
	margin-right:5px;
	width:15px;
}
button.btn i.active	{ background:url(http://s.twimg.com/a/1282150308/images/spinner.gif); }

/* properties for the element that is generated *after* following */
span.following	{  background:#ffd; padding:5px 10px; }
span.following span { width:10px; height:9px; margin-right:5px; display:inline-block; background:url("http://s.twimg.com/a/1282150308/images/sprite-icons.png") -160px -16px no-repeat; }
</pre><p>Most of the styling for this button goes onto the BUTTON element itself.  You&#8217;ll notice directives to round the button;  leaving the button sharp also please the eye.  Through the regular, hover, and active button states, check out how Twitter users the background position and colors to nicely modify the button without the need for additional images.  You&#8217;ll also notice Twitter uses sprites&#8230;as should you.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
/* with mootools */
window.addEvent('domready',function() {
	/* fetch elements */
	$$('form.follow-form').each(function(form) {
		/* stop form event */
		form.addEvent('submit',function(e) {
			/* stop event */
			if(e) e.stop();
			/* send ajax request */
			var i = form.getElement('i');
			new Request({
				url: 'twitter-follow.php',
				method: 'post',
				data: {
					followID: form.getElement('input').value
				},
				onRequest: function() {
					i.addClass('active');
				},
				onSuccess: function() {
					var button = form.getElement('button');
					button.setStyle('display','none');
					new Element('span',{
						html: '<span></span>Following!',
						'class': 'following'
					}).inject(button,'after');
				},
				onComplete: function() {
					i.removeClass('active');
				}
			}).send();
		});
	});
});
</pre><p>The first step is grabbing all of the FORM elements with the follow-form CSS class.  Upon form submission, the default submission action is stopped.  An AJAX request is fired, using the INPUT element&#8217;s ID as the user to follow.  When the request is fired, the I element&#8217;s background image is set to the spinner.  When the request is complete, the button is hidden and a new SPAN element is displayed informing the user that they are now following the given user!</p><h2>The jQuery&nbsp;JavaScript</h2><pre class="js">
// Idiomatic jQuery by Doug Neiner
jQuery(function ($) {
	/* fetch elements and stop form event */
	$("form.follow-form").submit(function (e) {
		/* stop event */
		e.preventDefault();
		/* "on request" */
		$(this).find('i').addClass('active');
		/* send ajax request */
		$.post('twitter-follow.php', {
			followID: $(this).find('input').val()
		}, function () {
			/* find and hide button, create element */
			$(e.currentTarget)
			  .find('button').hide()
			  .after('&lt;span class="following"&gt;&lt;span&gt;&lt;/span&gt;Following!&lt;/span&gt;');
		});
	});
});
</pre><p>The code above is based off of the MooTools code.  The workflow is exactly the same.</p><h2>The Dojo&nbsp;JavaScript</h2><pre class="js">
/* when the DOM is ready */
dojo.ready(function() {
	/* fetch elements */
	dojo.query('form.follow-form').forEach(function(form) {
		/* stop form event */
		dojo.connect(form,'onsubmit',function(e) {
			/* stop event */
			dojo.stopEvent(e);
			/* active class */
			dojo.query('i',form).addClass('active');
			/* get button */
			var button = dojo.query('button',form)[0];
			/* ajax request */
			dojo.xhrPost({
				form: form,
				load: function() {
					dojo.style(button,'display','none');
					dojo.create('span',{
						innerHTML: '<span></span>Following',
						className: 'following'
					},button,'after');
				}
			});
		});
	});
});
</pre><p>The code above is based off of the MooTools code.  The workflow is exactly the same.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php" class="demo">View MooTools Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=dojo" class="demo">View Dojo Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=jquery" class="demo">View jQuery Demo</a><div
class="clear"></div></div><p>This &#8220;Follow&#8221; button is only one of many details that Twitter has paid attention to, just to make the user experience on the site better.  Take note from the effort put forth by large websites &#8212; adding these types of details to your smaller websites can make the user experience much better for YOUR users!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/twitter-button">Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/dojo-ajax' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;Dojo'>Animated AJAX Record Deletion Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/animated-button' rel='bookmark' title='Permanent Link: Create an Animated Sliding Button Using&nbsp;MooTools'>Create an Animated Sliding Button Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;jQuery'>Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/twitter-button/feed</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&#160;III</title><link>http://davidwalsh.name/dojo-mootools-jquery</link> <comments>http://davidwalsh.name/dojo-mootools-jquery#comments</comments> <pubDate>Thu, 19 Aug 2010 02:32:54 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Dojo]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5045</guid> <description><![CDATA[My love of the JavaScript frameworks knows no bounds. Unfortunately too many developers stick to one framework without taking the time to learn the others. The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make. Let me show you how to accomplish a few more tasks using [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/dojo-mootools-jquery">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/jquery-mootools-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></li><li><a
href='http://davidwalsh.name/dojo-mootools' rel='bookmark' title='Permanent Link: Quick Dojo Setup Snippet for MooTools&nbsp;Developers'>Quick Dojo Setup Snippet for MooTools&nbsp;Developers</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<p>My love of the JavaScript frameworks knows no bounds.  Unfortunately too many developers stick to one framework without taking the time to learn the others.  The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make.  Let me show you how to accomplish a few more tasks using three JavaScript frameworks:  MooTools, jQuery, and Dojo.</p><h2>Calculate Element Dimensions and&nbsp;Position</h2><p>Knowing not only the height and width of a dimension but it&#8217;s top/left position from an offset parent or document body can be extremely helpful when trying to animate or move a DOM element.</p><h3>MooTools</h3><pre class="js">
var dimensions = document.id('myElement').getDimensions();
/* returns:
{ 
	height: 4684,
	width: 1408,
	x: 1408,
	y: 4684
}
*/
</pre><h3>jQuery</h3><pre class="js">
var myElement = jQuery('#myElement');
var position = myElement.position();
var dimensions = {
	height: myElement.height(),
	width: myElement.width(),
	top: position.top,
	left: position.left
};
</pre><h3>Dojo</h3><pre class="js">
var dimension = dojo.coords('myElement');
/* returns:
{
	h: 4684,
	l: 0,
	t: 0,
	w: 1408,
	x: 0,
	y: 0
}
*/
</pre><h2>Extend an&nbsp;Object</h2><p>Extending an object means taking on object and merging a second objects properties into it.  This is very helpful in merging default options with instance options.</p><h3>MooTools</h3><pre class="js">
$extend(firstObject,{ anotherProperty:'anothervalue' });
//second arg is added to the first object
</pre><h3>jQuery</h3><pre class="js">
jQuery.extend(firstObject,{ anotherProperty:'anothervalue' })
</pre><h3>Dojo</h3><pre class="js">
dojo.mixin(firstObject,{ anotherProperty:'anothervalue' });
</pre><h2>Stop an&nbsp;Event</h2><p>Stopping an event is helpful when looking to execute functionality (usually an XHR request) when a link is clicked.</p><h3>MooTools</h3><pre class="js">
$('myElement').addEvent('click',function(e) {
	e.stop();
});
</pre><h3>jQuery</h3><pre class="js">
$('#myElement').click(function(e){ 
	event.stopPropagation();
	e.preventDefault();
	// (no internal method that does both)
});
</pre><h3>Dojo</h3><pre class="js">
dojo.connect(dojo.byId('myElement'),'onclick',function(e) {
	dojo.stopEvent(e);
});
</pre><h2>Load Content into an&nbsp;Element</h2><p>Sure we can create an XHR request manually to load content into an element but why do that when your favorite lirbary can do that work for you?</p><h3>MooTools</h3><pre class="js">
document.id('myElement').load('ajax/script.html');
</pre><h3>jQuery</h3><pre class="js">
jQuery('#myElement').load('ajax/script.html');
</pre><h3>Dojo</h3><pre class="js">
//as found on Pete Higgins' website:
//http://higginsforpresident.net/2009/12/140-characters-of-awesome/
dojo.extend(dojo.NodeList, {
	grab: function(url){
		dojo.xhr('GET', { url:url })
			.addCallback(this, function(response){
				this.addContent(response, 'only');
			});
		return this;
	}
});
dojo.query('#myElement').grab('header.html');
</pre><h2>Get and Set HTML&nbsp;Content</h2><p>Getting and setting HTML is a frequent JavaScript operation&#8230;yet each library handles it a bit differently.</p><h3>MooTools</h3><pre class="js">
//get
var html = document.id('myElement').get('html');
//set
document.id('myElement').set('html','<b>Hello!</b>');
</pre><h3>jQuery</h3><pre class="js">
//get
var html = jQuery('#myElement').html();
//set
jQuery('#myElement').html('<b>Hello!</b>');
</pre><h3>Dojo</h3><pre class="js">
//get 
var html = dojo.byId('myElement').innerHTML
//set
dojo.byId('myElement').innerHTML = '<b>Hello!</b>';
</pre><h2>Use Element&nbsp;Storage</h2><p>Element data storage is important because it allows you to store settings within the element itself &#8212; perfect for defeating scope and context issues.</p><h3>MooTools</h3><pre class="js">
//set
document.id('myElement').store('key','value');
//get
var value = document.id('myElement').retrieve('key');
</pre><h3>jQuery</h3><pre class="js">
//set
jQuery('#myElement').data('key','value');
//get
var value = jQuery('#myElement').data('key');
</pre><h3>Dojo</h3><pre class="js">
//set
dojo.attr('myElement','data-key','value');
//get
dojo.attr('myElement','data-key');
</pre><p>There you are &#8212; more proof that the toolkits are one in the same, all except the syntax.  Do yourself a favor and learn more than one JavaScript framework &#8212; you&#8217;ll be better for it!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/dojo-mootools-jquery">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/jquery-mootools-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></li><li><a
href='http://davidwalsh.name/dojo-mootools' rel='bookmark' title='Permanent Link: Quick Dojo Setup Snippet for MooTools&nbsp;Developers'>Quick Dojo Setup Snippet for MooTools&nbsp;Developers</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/dojo-mootools-jquery/feed</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&#160;II</title><link>http://davidwalsh.name/jquery-mootools-dojo</link> <comments>http://davidwalsh.name/jquery-mootools-dojo#comments</comments> <pubDate>Wed, 11 Aug 2010 13:55:45 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Dojo]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5031</guid> <description><![CDATA[My love of the JavaScript frameworks knows no bounds.  Unfortunately too many developers stick to one framework without taking the time to learn the others.  The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make.  Let me show you how to accomplish a few more tasks using [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-mootools-dojo">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/dojo-mootools' rel='bookmark' title='Permanent Link: Quick Dojo Setup Snippet for MooTools&nbsp;Developers'>Quick Dojo Setup Snippet for MooTools&nbsp;Developers</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<p>My love of the JavaScript frameworks knows no bounds.  Unfortunately too many developers stick to one framework without taking the time to learn the others.  The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make.  Let me show you how to accomplish a few more tasks using three JavaScript frameworks:  MooTools, jQuery, and Dojo.</p><h2>Loop Through an Element&nbsp;Collection</h2><h3>MooTools</h3><pre class="js">
$$('div').each(function(div) {
	/* do stuff here */
});
</pre><h3>jQuery</h3><pre class="js">
jQuery('div').each(function(){ 
	/* do stuff;  "this" is the element */
});
</pre><h3>Dojo</h3><pre class="js">
dojo.query('div').forEach(function(div){ 
	/* do stuff */
});
</pre><h2>Get an Element Attribute&nbsp;Value</h2><h3>MooTools</h3><pre class="js">
var rel = document.id('myElement').get('rel');
</pre><h3>jQuery</h3><pre class="js">
var rel = jQuery('#myElement').attr('rel');
</pre><h3>Dojo</h3><pre class="js">
//var rel = dojo.query('#myElement').attr('rel')[0];
var rel = dojo.attr('myElement','rel');
</pre><h2>Create a Plugin / Class &#8211;&nbsp;Template</h2><h3>MooTools</h3><pre class="js">
var myClass = new Class({
	
	initialize: function(options) {
		/* do initial processing */
	}
	
});
</pre><h3>jQuery</h3><pre class="js">
jQuery.fn.myClass = function(options) {
	
	return this.each(function() {
		/* do initial processing */
	});
	
};
</pre><h3>Dojo</h3><pre class="js">
dojo.provide('mynamespace.PluginName');
dojo.declare('mynamespace.PluginName',null,{
	
	constructor: function(options) {
		/* do initial processing */
	}
	
});
</pre><h2>Set and Get Cookie&nbsp;Key=&gt;Values</h2><h3>MooTools</h3><pre class="js">
/* set */
Cookie.write('key','value',{ duration: 5 }); //5 days
/* get */
var cookieValue = Cookie.read('key');
</pre><h3>jQuery</h3><pre class="js">
/* 
	requires this plugin:  http://plugins.jquery.com/project/cookie
*/
/* set */
jQuery.cookie('key','value', { expires: 5 });
/* get */
var cookieValue = jQuery.cookie('key');
</pre><h3>Dojo</h3><pre class="js">
/* get dojo's cookie class */
dojo.require('dojo.cookie');
/* set */
dojo.cookie('key','value', { expires: 5 }); //5 days
/* get */
var cookieValue = dojo.cookie('key');
</pre><h2>Retrieve JSON via&nbsp;XHR</h2><h3>MooTools</h3><pre class="js">
var jsonRequest = new Request.JSON({
	url: 'info.json', 
	onSuccess: function(json){
    	/* do something with results */
	}
}).get();
</pre><h3>jQuery</h3><pre class="js">
jQuery.getJSON('info.json',function(json) {
	/* do something with results */
});
</pre><h3>Dojo</h3><pre class="js">
dojo.xhrGet({
	url: 'info.json',
	handleAs: 'json',
	load: function(json) {
		/* do something with results */
	}
});
</pre><p>There you are &#8212; more proof that the toolkits are one in the same, all except the syntax.  Do yourself a favor and learn more than one JavaScript framework &#8212; you&#8217;ll be better for it!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-mootools-dojo">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/dojo-mootools' rel='bookmark' title='Permanent Link: Quick Dojo Setup Snippet for MooTools&nbsp;Developers'>Quick Dojo Setup Snippet for MooTools&nbsp;Developers</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/jquery-mootools-dojo/feed</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>DomReady Event Methods in JavaScript&#160;Frameworks</title><link>http://davidwalsh.name/javascript-domready</link> <comments>http://davidwalsh.name/javascript-domready#comments</comments> <pubDate>Mon, 21 Jun 2010 13:56:48 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Dojo]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4992</guid> <description><![CDATA[The &#8220;domready&#8221; event, as it is affectionately known as, is one of the best things since sliced bread. The domready event says &#8220;screw you window.load &#8230; I don&#8217;t have time to wait for you.&#8221; The ability to execute your JavaScript method on DOM nodes before the page loads helps to make our effects and element [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/javascript-domready">DomReady Event Methods in JavaScript&nbsp;Frameworks</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-domready' rel='bookmark' title='Permanent Link: Quick Tip:  Faster DOMReady Checks with&nbsp;MooTools'>Quick Tip:  Faster DOMReady Checks with&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/javascript-frameworks-fight-mootools-jquery-prototype' rel='bookmark' title='Permanent Link: When JavaScript Frameworks&nbsp;Collide'>When JavaScript Frameworks&nbsp;Collide</a></li><li><a
href='http://davidwalsh.name/6-reasons-to-use-javascript-libraries-frameworks' rel='bookmark' title='Permanent Link: 6 Reasons To Use JavaScript Libraries &#038;&nbsp;Frameworks'>6 Reasons To Use JavaScript Libraries &#038;&nbsp;Frameworks</a></li><li><a
href='http://davidwalsh.name/mootools-from' rel='bookmark' title='Permanent Link: New MooTools Methods:&nbsp;.from()'>New MooTools Methods:&nbsp;.from()</a></li><li><a
href='http://davidwalsh.name/element-on' rel='bookmark' title='Permanent Link: Prototype&#8217;s Element.on with&nbsp;MooTools'>Prototype&#8217;s Element.on with&nbsp;MooTools</a></li></ol>]]></description> <content:encoded><![CDATA[<p>The &#8220;domready&#8221; event, as it is affectionately known as, is one of the best things since sliced bread.  The domready event says &#8220;screw you window.load &#8230; I don&#8217;t have time to wait for you.&#8221;  The ability to execute your JavaScript method on DOM nodes before the page loads helps to make our effects and element modifications that much more seamless.  Every JavaScript framework has their own method of domready so I wanted to take the time to list off each one, just in case you (or I) need to work with a framework that&#8217;s (initially) outside of our comfort zone.</p><h3>MooTools&nbsp;(FTW)</h3><pre class="js">
window.addEvent('domready',function() {
	//do stuff
});
</pre><h3>jQuery</h3><pre class="js">
jQuery(document).ready(function() {
	//do stuff
})
</pre><h3>Dojo&nbsp;Toolkit</h3><pre class="js">
dojo.addOnLoad(function() {
	//do stuff
});
</pre><h3>YUI</h3><pre class="js">
YUI().use('*',function(Y) {
	Y.on("domready", function() {
		//do stuff
	}, Y, "The DOMContentLoaded event fired.  The DOM is now safe to modify via script.");
});
</pre><h3>Prototype</h3><pre class="js">
document.observe("dom:loaded", function() { 
	//do stuff
});
</pre><h3>Sencha&nbsp;JS</h3><pre class="js">
Ext.onReady(function() {
	//do stuff
});
</pre><p>Be sure to let me know if I&#8217;m missing a framework &#8212; I&#8217;d like this list to become as comprehensive as possible!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/javascript-domready">DomReady Event Methods in JavaScript&nbsp;Frameworks</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-domready' rel='bookmark' title='Permanent Link: Quick Tip:  Faster DOMReady Checks with&nbsp;MooTools'>Quick Tip:  Faster DOMReady Checks with&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/javascript-frameworks-fight-mootools-jquery-prototype' rel='bookmark' title='Permanent Link: When JavaScript Frameworks&nbsp;Collide'>When JavaScript Frameworks&nbsp;Collide</a></li><li><a
href='http://davidwalsh.name/6-reasons-to-use-javascript-libraries-frameworks' rel='bookmark' title='Permanent Link: 6 Reasons To Use JavaScript Libraries &#038;&nbsp;Frameworks'>6 Reasons To Use JavaScript Libraries &#038;&nbsp;Frameworks</a></li><li><a
href='http://davidwalsh.name/mootools-from' rel='bookmark' title='Permanent Link: New MooTools Methods:&nbsp;.from()'>New MooTools Methods:&nbsp;.from()</a></li><li><a
href='http://davidwalsh.name/element-on' rel='bookmark' title='Permanent Link: Prototype&#8217;s Element.on with&nbsp;MooTools'>Prototype&#8217;s Element.on with&nbsp;MooTools</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/javascript-domready/feed</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>TextboxList for MooTools and jQuery by Guillermo&#160;Rauch</title><link>http://davidwalsh.name/mootools-jquery-textbox-list</link> <comments>http://davidwalsh.name/mootools-jquery-textbox-list#comments</comments> <pubDate>Tue, 15 Jun 2010 05:54:20 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4989</guid> <description><![CDATA[I&#8217;ll be honest with you: I still haven&#8217;t figured out if I like my MooTools teammate Guillermo Rauch. He&#8217;s got a lot stacked up against him. He&#8217;s from Argentina so I get IM&#8217;ed about 10 times a day about how great Lionel Messi is. He lives in California so he doesn&#8217;t have to deal with [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-jquery-textbox-list">TextboxList for MooTools and jQuery by Guillermo&nbsp;Rauch</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/editable-content-mootools-php-mysql' rel='bookmark' title='Permanent Link: Editable Content Using MooTools 1.2, PHP, and&nbsp;MySQL'>Editable Content Using MooTools 1.2, PHP, and&nbsp;MySQL</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/color-palette-generator-jquery' rel='bookmark' title='Permanent Link: Color Palette Generator Using&nbsp;jQuery'>Color Palette Generator Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/album-art' rel='bookmark' title='Permanent Link: Sexy Album Art with MooTools or&nbsp;jQuery'>Sexy Album Art with MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://davidwalsh.name/dw-content/textboxlist.php"><img
src="http://davidwalsh.name/dw-content/textboxlist.png" alt="MooTools jQuery TextboxList" /></a><p>I&#8217;ll be honest with you:  I still haven&#8217;t figured out if I like my MooTools teammate Guillermo Rauch.  He&#8217;s got a lot stacked up against him.  He&#8217;s from Argentina so I get IM&#8217;ed about 10 times a day about how great Lionel Messi is.  He lives in California so he doesn&#8217;t have to deal with 3 months of bitter cold like I do in Madison.  He even takes some of my chicks.  All that said&#8230;he&#8217;s just&#8230;just&#8230;so damn smart.  In the end I think some of my bitterness about Guiller is that he&#8217;s smarter than me.  Better than me at MooTools, JavaScript, and even life.</p><p>Evidence of Guiller&#8217;s FTW-age can be found in his TextboxList plugin.  TextboxList is a Facebook-style input list originally used by a small startup called Facebook.  TextbloxList is available in both MooTools and jQuery flavors and is incredibly easy to implement.  Lets walk through a simple example.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/textboxlist.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;HTML</h2><pre class="html">
<p>Enter tags (with commas)</p>
<div class="form_tags"><input type="text" name="test2" value="" id="myListElement" /></div>
<p class="note">Type the tag (one or more words) and press comma (,). Use left/right arrows, backspace, delete to navigate</p>
</pre><p>An input element.  That&#8217;s it. <em>(Editor&#8217;s note:  Sometimes I don&#8217;t understand why I even put a small description of the HTML portion of my code examples.  Since I follow the &#8220;JS for enhancements&#8221; philosophy, the HTML part is usually self-explanatory. &#8230;.That is all.)</em></p><h2>The&nbsp;CSS</h2><pre class="css">
.textboxlist { font: 11px "Lucida Grande", Verdana; cursor: text; }
.textboxlist-bits { zoom: 1; overflow: hidden; margin: 0; padding: 3px 4px 0; border: 1px solid #999; *padding-bottom: 3px; }
.textboxlist-bit { list-style-type: none; float: left; display: block; padding: 0; margin: 0 5px 3px 0; cursor: default; }
.textboxlist-bit-editable { border: 1px solid #fff; }
.textboxlist-bit-editable-input { border: 0; padding: 2px 0; *padding-bottom: 0; height: 14px; font: 11px "Lucida Grande", Verdana; }
.textboxlist-bit-editable-input:focus { outline: 0; }
.textboxlist-bit-box { position: relative; line-height: 18px; padding: 0 5px; -moz-border-radius: 9px; -webkit-border-radius: 9px; border-radius: 9px; border: 1px solid #CAD8F3; background: #DEE7F8; cursor: default; }
.textboxlist-bit-box-deletable { padding-right: 15px; }
.textboxlist-bit-box-deletebutton { position: absolute; right: 4px; top: 6px; display: block; width: 7px; height: 7px; font-size: 1px; background: url('close.gif'); }
.textboxlist-bit-box-deletebutton:hover { border: none; background-position: 7px; text-decoration: none; }
.textboxlist-bit-box-hover { background: #BBCEF1; border: 1px solid #6D95E0; }
.textboxlist-bit-box-focus { border-color: #598BEC; background: #598BEC; color: #fff; }
.textboxlist-bit-box-focus .textboxlist-bit-box-deletebutton { background-position: bottom; }
</pre><p>TextboxList comes with its own CSS stylesheet so the CSS portion is done for you.  There&#8217;s only one image required for TextboxList and it&#8217;s sprited, at that.  Guiller doesn&#8217;t leave anything unoptimized. <em>(Editor&#8217;s note:  Guiller&#8217;s attention to detail both impresses me and pisses me off.)</em></p><h2>The MooTools&nbsp;Usage</h2><pre class="js">
//create an instance 
var t2 = new TextboxList('myListElement', {bitsOptions:{editable:{addKeys: 188}}});
//add a few just for giggles
t2.add('Tag 1').add('Tag 2');
</pre><p>The above example is an extremely simple usage &#8212; type a name, add a comma, and you can see the effect immediately.  What&#8217;s even more awesome is that the plugin is keyboard-compatible, meaning you can press the arrow keys to move &#8220;over&#8221; or between items, and even delete them.  Essentially you never have to use your mouse.  Also of note is that Guillermo&#8217;s TextboxList class works with a bundled autocomplete plugin so you may quickly hook TextboxList in with your database. <em>(Editor&#8217;s note:  There&#8217;s also a special autocomplete snippet for binary searches&#8230;.Yeah, I know, I bet you&#8217;re probably starting to dislike him too&#8230;)</em></p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/textboxlist.php" class="demo">View Demo</a><div
class="clear"></div></div><a
href="http://davidwalsh.name/dw-content/textboxlist.php"><img
src="http://davidwalsh.name/dw-content/textboxlist.png" alt="MooTools jQuery TextboxList" /></a><p>All jokes aside, Guillermo Rauch is an awesome developer.  You can <a
href="http://twitter.com/rauchg">follow him on Twitter</a>, poach his code on <a
href="http://github.com/guille">GitHub</a> (he&#8217;s a Node.js guru as well), or <a
href="http://devthought.com">check out his musings on his blog</a>.  He also has project pages created for both the <a
href="http://devthought.com/projects/mootools/textboxlist/">MooTools</a> and <a
href="http://devthought.com/projects/jquery/textboxlist/">jQuery</a> versions of TextboxList so be sure to hit those to get the details on class options, events, and usages.</p><p>If you do by chance get a moment to throw a tweet at him be sure to thank him for creating the <a
href="http://mootools.net/forge">MooTools Forge</a>!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-jquery-textbox-list">TextboxList for MooTools and jQuery by Guillermo&nbsp;Rauch</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/editable-content-mootools-php-mysql' rel='bookmark' title='Permanent Link: Editable Content Using MooTools 1.2, PHP, and&nbsp;MySQL'>Editable Content Using MooTools 1.2, PHP, and&nbsp;MySQL</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/color-palette-generator-jquery' rel='bookmark' title='Permanent Link: Color Palette Generator Using&nbsp;jQuery'>Color Palette Generator Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/album-art' rel='bookmark' title='Permanent Link: Sexy Album Art with MooTools or&nbsp;jQuery'>Sexy Album Art with MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-jquery-textbox-list/feed</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&#160;JavaScript</title><link>http://davidwalsh.name/github-css</link> <comments>http://davidwalsh.name/github-css#comments</comments> <pubDate>Thu, 20 May 2010 13:51:33 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Dojo]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4970</guid> <description><![CDATA[I&#8217;m what you would consider a bit of a GitHub fanboy. We all know that GitHub is the perfect place to store repositories of open source code, but I think my love of GitHub goes beyond that. GitHub seems to understand that most repo sites are usually boring so they&#8217;ve spiced their site up with [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/github-css">Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/skype-mootools' rel='bookmark' title='Permanent Link: Skype-Style Buttons Using&nbsp;MooTools'>Skype-Style Buttons Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/dojo-tooltips' rel='bookmark' title='Permanent Link: Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo'>Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://davidwalsh.name/dw-content/github-button.php"><img
src="http://davidwalsh.name/dw-content/github-buttons.jpg" alt="GitHub Buttons" class="image" /></a><p>I&#8217;m what you would consider a bit of a GitHub fanboy.  We all know that GitHub is the perfect place to store repositories of open source code, but I think my love of GitHub goes beyond that.  GitHub seems to understand that most repo sites are usually boring so they&#8217;ve spiced their site up with some catchy CSS and great JavaScript features.  One tiny piece of the GitHub design I love are the basic buttons.  Lets examine how we can create our own GitHub-style buttons with a bit of HTML, CSS, and JavaScript.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/github-button.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;HTML</h2><pre class="html">
&lt;!-- button 1:"plain" --&gt;
&lt;a href="javascript:;" class="minibutton"&gt;&lt;span&gt;Basic Button&lt;/span&gt;&lt;/a&gt;
&lt;!-- button 2:"icon" --&gt;
&lt;a href="javascript:;" class="minibutton btn-download"&gt;&lt;span&gt;&lt;span class="icon"&gt;&lt;/span&gt;Button With Icon&lt;/span&gt;&lt;/a&gt;
</pre><p>Below are two styles of buttons:  one basic button and one with an icon to the left of the text.</p><h2>The&nbsp;CSS</h2><pre class="css">
	/* button basics */
	a.minibutton {
		display:inline-block;
		height:23px;
		padding:0 0 0 3px;
		font-size:11px;
		font-weight:bold;
		color:#333;
		text-shadow:1px 1px 0 #fff; 
		background:url(http://github.com/images/modules/buttons/minibutton_matrix.png) 0 0 no-repeat;
		white-space:nowrap;
		border:none;
		overflow:visible;
		cursor:pointer;
		text-decoration:none;
	}
	
	a.minibutton&gt;span {
		display:block;
		height:23px;
		padding:0 10px 0 8px;
		line-height:23px;
		background:url(http://github.com/images/modules/buttons/minibutton_matrix.png) 100% 0 no-repeat;
	}
	
	a.minibutton:hover, a.minibutton:focus {
		color:#fff;
		text-decoration:none;
		text-shadow:-1px -1px 0 rgba(0,0,0,0.3);
		background-position:0 -30px;
	}
	a.minibutton:hover&gt;span, a.minibutton:focus&gt;span {background-position:100% -30px;}
	
	a.minibutton.mousedown{background-position:0 -60px; }
	a.minibutton.mousedown&gt;span{background-position:100% -60px; }
	
	/* with icon */
	a.btn-download .icon {
		float:left;
		margin-left:-4px;
		width:18px;
		height:22px;
		background:url(http://github.com/images/modules/buttons/minibutton_icons.png?v20100306) 0 0 no-repeat;
	}
	a.btn-download .icon {background-position:-40px 0;}
	a.btn-download:hover .icon, a.btn-download:focus .icon {background-position:-40px -25px;}
</pre><p>The CSS is bountiful but it usually is when trying to achieve perfection.  And just like most buttons, the GitHub button is an A element with a series of SPAN elements inside of it.  You&#8217;ll also note more CSS code is needed to accommodate for the button&#8230;obviously.</p><h2>The MooTools, Dojo, or jQuery&nbsp;JavaScript</h2><pre class="js">
/* MooTools (FTW) */
window.addEvent('domready',function() {
	$$('a.minibutton').addEvents({
		mousedown: function() {
			this.addClass('mousedown');
		},
		blur: function() {
			this.removeClass('mousedown');
		},
		mouseup: function() {
			this.removeClass('mousedown');
		}
	});
});

/* Dojo Toolkit */
dojo.addOnLoad(function() {
	var buttons = dojo.query('a.minibutton');
	buttons.connect('onmousedown',function() { dojo.addClass(this,'mousedown'); });
	buttons.connect('onblur',function() { dojo.removeClass(this,'mousedown'); });
	buttons.connect('onmouseup',function() { dojo.removeClass(this,'mousedown'); });
});

/* jQuery */
jQuery.ready(function() {
	jQuery('a.minibutton').bind({
		mousedown: function() {
			jQuery(this).addClass('mousedown');
		},
		blur: function() {
			jQuery(this).removeClass('mousedown');
		},
		mouseup: function() {
			jQuery(this).removeClass('mousedown');
		}
	});
});
</pre><p>GitHub gets it right by making the JavaScript portion <em>only</em> serve as an enhancement for button focus/mousedown.  This JavaScript is not required.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/github-button.php" class="demo">View Demo</a><div
class="clear"></div></div><p>In the end, the amount of CSS and JavaScript used is probably more than you would have thought but the result is really smooth.  Feel free to profess your own love for GitHub below.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/github-css">Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/skype-mootools' rel='bookmark' title='Permanent Link: Skype-Style Buttons Using&nbsp;MooTools'>Skype-Style Buttons Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/dojo-tooltips' rel='bookmark' title='Permanent Link: Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo'>Duplicate the jQuery Homepage Tooltips Using&nbsp;Dojo</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/github-css/feed</wfw:commentRss> <slash:comments>22</slash:comments> </item> <item><title>Accomplishing Common Tasks Using MooTools, jQuery, and&#160;Dojo</title><link>http://davidwalsh.name/mootools-jquery-dojo</link> <comments>http://davidwalsh.name/mootools-jquery-dojo#comments</comments> <pubDate>Thu, 22 Apr 2010 12:22:29 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Dojo]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4954</guid> <description><![CDATA[I&#8217;ve been dabbling with Dojo quite a bit lately. I feel great about my MooTools and jQuery skills but I&#8217;m a bit still raw when it comes to Dojo. What&#8217;s important that I keep in mind, however, is that the tasks I&#8217;m trying to accomplish are the same &#8212; the syntax is simply different. Here [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-jquery-dojo">Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/jquery-mootools-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been dabbling with Dojo quite a bit lately.  I feel great about my MooTools and jQuery skills but I&#8217;m a bit still raw when it comes to Dojo.  What&#8217;s important that I keep in mind, however, is that the tasks I&#8217;m trying to accomplish are the same &#8212; the syntax is simply different.  Here are a few basic JavaScript tasks and the syntax to accomplish them within each awesome framework.</p><h2>Execute Code when the DOM is&nbsp;Ready</h2><h3>Dojo&nbsp;Toolkit</h3><pre class="js">
dojo.ready(function() {
	//do stuff
});
</pre><h3>jQuery</h3><pre class="js">
jQuery(document).ready(function() {
	//do stuff
});
</pre><h3>MooTools</h3><pre class="js">
window.addEvent('domready',function() {
	//do stuff
});
</pre><br
/><h2>Collect&nbsp;Elements</h2><h3>Dojo&nbsp;Toolkit</h3><pre class="js">
var myElement = dojo.byId('myElement');
var divs = dojo.query('div');
</pre><h3>jQuery</h3><pre class="js">
var myElement = jQuery('#myElement');
var divs = jQuery('div');
</pre><h3>MooTools</h3><pre class="js">
var myElement = document.id('myElement');
var divs = $$('div');
</pre><br
/><h2>Create Event&nbsp;Listeners</h2><h3>Dojo&nbsp;Toolkit</h3><pre class="js">
dojo.connect(dojo.byId('myElement'),'onclick',function() {
	alert('You clicked me!');
});
</pre><h3>jQuery</h3><pre class="js">
jQuery('#myElement').click(function() {
	alert('You clicked me!');
});
</pre><h3>MooTools</h3><pre class="js">
document.id('myElement').addEvent('click',function() {
	alert('You clicked me!');
});
</pre><br
/><h2>Create a New Element, Inject Into&nbsp;Document.Body</h2><h3>Dojo&nbsp;Toolkit</h3><pre class="js">
dojo.create('div',{
	innerHTML: 'This is a new element',
	id: 'myElement'
},dojo.body());
</pre><h3>jQuery</h3><pre class="js">
jQuery('&lt;div id=&quot;myElement&quot;&gt;This is a new element&lt;/div&gt;').appendTo('body');
</pre><h3>MooTools</h3><pre class="js">
new Element('div',{
	id: 'myElement',
	text: 'This is a new element'
}).inject(document.body);
</pre><br
/><h2>Execute AJAX&nbsp;Requests</h2><h3>Dojo&nbsp;Toolkit</h3><pre class="js">
dojo.xhrPost({
	url: 'save.php',
	content: {
		id: dojo.byId('user-id').value
	}
	load: function(response) {
		alert('Received the following response:  ' + response);
	}
});
</pre><h3>jQuery</h3><pre class="js">
jQuery.ajax({
	url: 'save.php',
	type: 'post',
	data: {
		id: jQuery('#user-id').val()
	},
	success: function(response) {
		alert('Received the following response:  ' + response);
	}
});
</pre><h3>MooTools</h3><pre class="js">
new Request({
	url: 'save.php',
	method: 'post',
	data: {
		id: document.id('user-id').value
	},
	onSuccess: function(response) {
		alert('Received the following response:  ' + response);
	}
}).send();
</pre><br
/><h2>Animate the Opacity of an&nbsp;Element</h2><h3>Dojo&nbsp;Toolkit</h3><pre class="js">
dojo.anim('myElement',{ opacity: 0.7 }, 250);
</pre><h3>jQuery</h3><pre class="js">
jQuery('#myElement').fadeTo(250,0.7);
//duration first...ftl
</pre><h3>MooTools</h3><pre class="js">
document.id('myElement').set('tween',{ duration: 250 }).fade(0.7);
</pre><p>See?  Dojo, jQuery, and MooTools aren&#8217;t that different.  Same problems, different solution syntax.  Like <a
href="http://higginsforpresident.net" rel="nofollow">Pete Higgins</a> says:  It&#8217;s just JavaScript!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-jquery-dojo">Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/jquery-mootools-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-jquery-dojo/feed</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>Create Twitter-Style Dropdowns Using&#160;jQuery</title><link>http://davidwalsh.name/twitter-dropdown-jquery</link> <comments>http://davidwalsh.name/twitter-dropdown-jquery#comments</comments> <pubDate>Tue, 16 Mar 2010 13:10:11 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4930</guid> <description><![CDATA[Twitter does some great stuff with JavaScript. What I really appreciate about what they do is that there aren&#8217;t any epic JS functionalities &#8212; they&#8217;re all simple touches. One of those simple touches is the &#8220;Login&#8221; dropdown on their homepage. I&#8217;ve taken some time to duplicate that functionality with jQuery. View Demo The&#160;HTML &#60;div id=&#34;menu1&#34;&#62;&#60;div [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/twitter-dropdown-jquery">Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/twitter-dropdown' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;MooTools'>Create Twitter-Style Dropdowns Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/mootools-outter-click' rel='bookmark' title='Permanent Link: Track Clicks Outside Active Elements with MooTools or&nbsp;jQuery'>Track Clicks Outside Active Elements with MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://davidwalsh.name/dw-content/twitter-dropdown-jquery.php"><img
src="http://davidwalsh.name/dw-content/fail-whale.png" alt="Twitter Dropdown" class="image" /></a><p>Twitter does some great stuff with JavaScript.  What I really appreciate about what they do is that there aren&#8217;t any epic JS functionalities &#8212; they&#8217;re all simple touches.  One of those simple touches is the &#8220;Login&#8221; dropdown on their homepage.  I&#8217;ve taken some time to duplicate that functionality with jQuery.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/twitter-dropdown-jquery.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;HTML</h2><pre class="html">
&lt;div id=&quot;menu1&quot;&gt;&lt;div class=&quot;relative&quot;&gt;
	&lt;a href=&quot;/demos&quot; title=&quot;Popular MooTools Tutorials&quot; id=&quot;dd1&quot; class=&quot;dropdown&quot; style=&quot;width:170px;text-decoration:none;&quot;&gt;&lt;span&gt;Menu 1&lt;/span&gt;&lt;/a&gt;
	&lt;div id=&quot;dropdown1&quot; class=&quot;dropdown-menu&quot;&gt;
		&lt;a href=&quot;/about-david-walsh&quot; title=&quot;Learn a bit about me.&quot;&gt;About Me&lt;/a&gt;
		&lt;a href=&quot;/page/1&quot; title=&quot;The David Walsh Blog&quot;&gt;Blog&lt;/a&gt;
		&lt;a href=&quot;/chat&quot; title=&quot;#davidwalshblog IRC Chat&quot;&gt;Chat&lt;/a&gt;
		&lt;a href=&quot;/contact&quot; title=&quot;Contact David Walsh&quot;&gt;Contact Me&lt;/a&gt;
		&lt;a href=&quot;/demos&quot; title=&quot;CSS, PHP, jQuery, MooTools Demos&quot;&gt;Demos &amp;amp; Downloads&lt;/a&gt;
		&lt;a href=&quot;/js&quot; title=&quot;ScrollSpy, Lazyload, Overlay, Context Menu&quot;&gt;MooTools Plugins&lt;/a&gt;
		&lt;a href=&quot;/network&quot; title=&quot;David Walsh Blog, Script &amp;amp; Style, Band Website Template, Wynq&quot;&gt;Network&lt;/a&gt;
		&lt;a href=&quot;/web-development-tools&quot; title=&quot;JS, CSS Compression&quot;&gt;Web Dev Tools&lt;/a&gt;
	&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;div id=&quot;menu2&quot;&gt;&lt;div class=&quot;relative&quot;&gt;
	&lt;a href=&quot;/demos&quot; title=&quot;Popular MooTools Tutorials&quot; id=&quot;dd2&quot; class=&quot;dropdown&quot; rel=&quot;dropdown2&quot; style=&quot;width:170px;text-decoration:none;&quot;&gt;&lt;span&gt;Menu 2&lt;/span&gt;&lt;/a&gt;
	&lt;div id=&quot;dropdown2&quot; class=&quot;dropdown-menu&quot;&gt;
		&lt;p&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.&lt;/p&gt;
	&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;
</pre><p>A series of DIVS wrapping a link (the dropdown &#8220;trigger&#8221;) and a DIV containing the menu items.</p><h2>The&nbsp;CSS</h2><pre class="css">
/* dropdowns: general */
a.dropdown { background: #88bbd4; padding: 4px 6px 6px; text-decoration: none; font-weight: bold; color: #fff; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; }
a.dropdown:hover { background: #59b; }
a.dropdown { position: relative; margin-left: 3px; }
a.dropdown span { background-image: url(toggle_down_light.png); background-repeat: no-repeat; background-position: 100% 50%; padding: 4px 16px 6px 0; }
a.dropdown.dropdown-active { color:#59b; background-color:#ddeef6; }
a.dropdown.dropdown-active span { background:url(toggle_up_dark.png) 100% 50% no-repeat; }
.dropdown-menu	{ background:#ddeef6; padding:7px 12px; position:absolute; top:16px; right:0; display:none; z-index:5000; -moz-border-radius-topleft: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; }
	.dropdown-menu p { font-size:11px; }
.dropdown-menu a:link, .dropdown-menu a:visited	{ font-weight:bold; color:#59b; text-decoration:none; line-height:1.7em; }
.dropdown-menu a:active, .dropdown-menu a:hover { color:#555; }

			* html .dropdown-menu { top:28px; }
			*+ html .dropdown-menu { top:28px; }

/* dropdowns: specific */
#menu1			{ float:left; margin-right:20px; }
	#dropdown1	{ width:150px; }
	#dropdown1 a	{ display:block; }
#menu2			{ float:left; }
	#dropdown2	{ width:150px; font-size:11px; }
.relative		{ position:relative; }
</pre><p>There&#8217;s a lot of CSS involved but most of it is simple visual styling as opposed to styling for JavaScript&#8217;s sake.  Do, however, note where relative and absolute positioning is used.  The outermost DIV may be positioned absolutely if you&#8217;d like.  Also note that I&#8217;m not doing anything to accommodate for rounded corners in IE &#8212; I recommend <a
href="http://www.dillerdesign.com/experiment/DD_roundies/" rel="nofollow" target="_blank">DD_Roundies</a> for that.</p><h2>The jQuery&nbsp;JavaScript</h2><pre class="javascript">
$(document).ready(function() {
	/* for keeping track of what's "open" */
	var activeClass = 'dropdown-active', showingDropdown, showingMenu, showingParent;
	/* hides the current menu */
	var hideMenu = function() {
		if(showingDropdown) {
			showingDropdown.removeClass(activeClass);
			showingMenu.hide();
		}
	};
	
	/* recurse through dropdown menus */
	$('.dropdown').each(function() {
		/* track elements: menu, parent */
		var dropdown = $(this);
		var menu = dropdown.next('div.dropdown-menu'), parent = dropdown.parent();
		/* function that shows THIS menu */
		var showMenu = function() {
			hideMenu();
			showingDropdown = dropdown.addClass('dropdown-active');
			showingMenu = menu.show();
			showingParent = parent;
		};
		/* function to show menu when clicked */
		dropdown.bind('click',function(e) {
			if(e) e.stopPropagation();
			if(e) e.preventDefault();
			showMenu();
		});
		/* function to show menu when someone tabs to the box */
		dropdown.bind('focus',function() {
			showMenu();
		});
	});
	
	/* hide when clicked outside */
	$(document.body).bind('click',function(e) {
		if(showingParent) {
			var parentElement = showingParent[0];
			if(!$.contains(parentElement,e.target) || !parentElement == e.target) {
				hideMenu();
			}
		}
	});
});

</pre><p>I&#8217;ve commented to the code to illustrate what each block does.  In a nutshell:</p><ul><li>I create placeholder variables which will keep track of the current menu, dropdown, and parent for the opened menu<em>.</em> This functionality is only included because I don&#8217;t want more than one menu to be open at a time.</li><li>I create a function that hides the current menu &#8212; this can be used from anywhere within the closure.</li><li>I cycle through each dropdown and add events to relevant elements to show and hide menus.</li><li>I add an event to the body to close the current menu if the user clicks outside of the menu.</li></ul><p>That&#8217;s it!</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/twitter-dropdown-jquery.php" class="demo">View Demo</a><div
class="clear"></div></div><p>Be sure to check out the <a
href="http://davidwalsh.name/twitter-dropdown">MooTools version</a>.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/twitter-dropdown-jquery">Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/twitter-dropdown' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;MooTools'>Create Twitter-Style Dropdowns Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/mootools-outter-click' rel='bookmark' title='Permanent Link: Track Clicks Outside Active Elements with MooTools or&nbsp;jQuery'>Track Clicks Outside Active Elements with MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/twitter-dropdown-jquery/feed</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>jQuery Podcast &amp; Essential jQuery and MooTools&#160;Snippets</title><link>http://davidwalsh.name/jquery-podcast</link> <comments>http://davidwalsh.name/jquery-podcast#comments</comments> <pubDate>Fri, 26 Feb 2010 15:24:03 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Blog]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4892</guid> <description><![CDATA[Many of you probably already know this but I like to consider myself a bit of a JavaScript chameleon. If you know that then you probably know I&#8217;m a MooTools fanatic that periodically dabbles with jQuery. I&#8217;m happy to announce that I was able to join Elijah Manor and Ralph Whitbeck on the jQuery podcast [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-podcast">jQuery Podcast &#038; Essential jQuery and MooTools&nbsp;Snippets</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/jquery-link-nudge' rel='bookmark' title='Permanent Link: jQuery Link Nudge&nbsp;Plugin'>jQuery Link Nudge&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/implement-jquery-mootools-event' rel='bookmark' title='Permanent Link: Implementing jQuery-Like Event Syntax in&nbsp;MooTools'>Implementing jQuery-Like Event Syntax in&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/faceoff-show' rel='bookmark' title='Permanent Link: David Walsh on the Faceoff Show&nbsp;Podcast'>David Walsh on the Faceoff Show&nbsp;Podcast</a></li><li><a
href='http://davidwalsh.name/jquery-mootools' rel='bookmark' title='Permanent Link: Using jQuery and MooTools&nbsp;Together'>Using jQuery and MooTools&nbsp;Together</a></li><li><a
href='http://davidwalsh.name/count-mootools-events' rel='bookmark' title='Permanent Link: Count MooTools Events Per Element in MooTools&nbsp;1.2'>Count MooTools Events Per Element in MooTools&nbsp;1.2</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://blog.jquery.com/2010/02/26/the-official-jquery-podcast-episode-13-david-walsh/" rel="nofollow"><img
src="http://davidwalsh.name/dw-content/jquery-logo.jpg" class="image" alt="jQuery" /></a><p>Many of you probably already know this but I like to consider myself a bit of a JavaScript chameleon.  If you know that then you probably know I&#8217;m a MooTools fanatic that periodically dabbles with jQuery.  I&#8217;m happy to announce that I was able to join Elijah Manor and Ralph Whitbeck on the jQuery podcast this past week to talk jQuery, MooTools, and web development in general.  Head on over to the <a
href="http://blog.jquery.com/2010/02/26/the-official-jquery-podcast-episode-13-david-walsh/" rel="nofollow">jQuery blog</a> for more information or <a
href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=339835419" rel="nofollow">iTunes to grab the podcast</a>.</p><p>As an extension of my podcast appearance, I wanted to share a few code snippets to make your introduction to MooTools or jQuery easier.</p><h2>Featured jQuery &amp; MooTools&nbsp;Snippets</h2><h3>Using jQuery and MooTools&nbsp;Together</h3><p>Did you know that you can use jQuery and MooTools within the same page?  It&#8217;s easy to!</p><pre class="js">
&lt;script type=&quot;text/javascript&quot; src=&quot;moo1.2.4.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.4.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
window.addEvent('domready',function() { //moo stuff
	$('p').css('border','1px solid #fc0'); //jquery
});
&lt;/script&gt;
</pre><h3>Using Sizzle Within&nbsp;MooTools</h3><p>Prefer to use jQuery&#8217;s selector engine within MooTools?  No problem &#8212; here&#8217;s how:</p><pre class="js">
//just as reader &quot;Ryan&quot; mentioned....
Window.$$ = function(selector){
	return new Elements(new Sizzle(selector));
}
</pre><h3>jQuery and MooTools Link&nbsp;Nudging</h3><p>Link nudging is a classy, subtle effect that makes your websites more dynamic.</p><pre class="js">
/* jquery */
$.fn.nudge = function(params) {
	//set default parameters
	params = $.extend({
		amount: 20,
		duration: 300,
		property: 'padding',
		direction: 'left',
		toCallback: function() {},
		fromCallback: function() {}
	}, params);
	//For every element meant to nudge...
	this.each(function() {
		//variables
		var $t = $(this);
		var $p = params;
		var dir = $p.direction;
		var prop = $p.property + dir.substring(0,1).toUpperCase() + dir.substring(1,dir.length);
		var initialValue = $t.css(prop);
		/* fx */
		var go = {}; go[prop] = parseInt($p.amount) + parseInt(initialValue);
		var bk = {}; bk[prop] = initialValue;
		
		//Proceed to nudge on hover
		$t.hover(function() {
					$t.stop().animate(go, $p.duration, '', $p.toCallback);
				}, function() {
					$t.stop().animate(bk, $p.duration, '', $p.fromCallback);
				});
	});
	return this;
};

/* jquery usages */
$(document).ready(function() {
	/* usage 1 */
	$('#nudgeUs li a').nudge();
	/* usage 2 */
	$('#nudgeUs2 li a').nudge({
		property: 'margin',
		direction: 'left',
		amount: 30,
		duration: 400,
		toCallback: function() { $(this).css('color','#f00'); },
		fromCallback: function() { $(this).css('color','#000'); }
	});
});

/* mootols link nudge */
window.addEvent('domready',function() {
	$$('#nudges a').addEvents({
		'mouseenter': function() { this.tween('padding-left',20); },
		'mouseleave': function() { this.tween('padding-left',0); }
	});
});
</pre><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/jquery-link-nudge-plugin.php" class="demo">View jQuery Demo</a> <a
href="http://davidwalsh.name/dw-content/mootools-link-nudge.php" class="demo">View MooTools Demo</a><div
class="clear"></div></div><h3>jQuery and MooTools Search&nbsp;Bookmarklets</h3><p>These bookmarklets will allow you to highlight text on a page and search the jQuery or MooTools websites to learn more about the phrase.</p> <a
href="javascript:(function()%7Bvar%20d=document,w=window,ds=d.getSelection,ws=w.getSelection,ss=d.selection,e=encodeURIComponent;t=(ws)%3Fws():(ds)%3Fds():(ss)%3Fss.createRange().text:'';t=(t.toString().length)%3Ft:prompt('Please select the code you would like to research.','');if(t)%7Ba='http://docs.jquery.com/Special:Search?search=';u=a+e(t);f=function()%7Bx=w.open(u,'nfx','scrollbars=1,toolbar=0,resizable=1,status=1,width=600,height=600');if(!x)w.location.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(f,0);else%20f();%7D%7D)();" class="article">jQuery Bookmarklet</a><a
href="javascript:(function()%7Bvar%20d=document,w=window,ds=d.getSelection,ws=w.getSelection,ss=d.selection,e=encodeURIComponent;t=(ws)%3Fws():(ds)%3Fds():(ss)%3Fss.createRange().text:'';t=(t.toString().length)%3Ft:prompt('Please select the code you would like to research.','');if(t)%7Ba='http://mootools.net/search/?search=1&#038;query=';u=a+e(t);f=function()%7Bx=w.open(u,'nfx','scrollbars=1,toolbar=0,resizable=1,status=1,width=800,height=600');if(!x)w.location.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(f,0);else%20f();%7D%7D)();" class="article">MooTools Bookmarklet</a><div
class="clear"></div><p>&nbsp;</p><h3>jQuery Events within&nbsp;MooTools</h3><p>The following MooTools snippet allows you to use jQuery-style syntax for event listening.</p><pre class="js">
//hash the element.natives so we can do stuff with it
var hash = new Hash(Element.NativeEvents);
//remove items that need to be replaced, add their replacements
hash.erase('mouseover').erase('mouseout').erase('DOMMouseScroll');
hash.include('mouseenter',1).include('mouseleave',1);
//initialize this
var eventHash = new Hash({});
//for every event type, add to our hash
hash.getKeys().each(function(event){
	eventHash[event] = function(fn) {
		this.addEvent(event,fn);
		return this;
	}
});
//make it happen
Element.implement(eventHash);
</pre><p>&nbsp;</p><h2>JavaScript&nbsp;FTW!</h2><p>Here are a few other MooTools and jQuery tutorials you may like:</p><ul><li><a
href="http://davidwalsh.name/animate-opacity">Sexy Opacity Animation with MooTools or jQuery</a></li><li><a
href="http://davidwalsh.name/google-fade">Google-Style Element Fading Using MooTools or jQuery</a></li><li><a
href="http://davidwalsh.name/iphone-click">iPhone Click Effect Using MooTools or jQuery</a></li><li><a
href="http://davidwalsh.name/text-selection-ajax">Record Text Selections Using MooTools or jQuery AJAX</a></li><li><a
href="http://davidwalsh.name/remove-broken-images">Remove Broken Images Using MooTools or jQuery</a></li><li><a
href="http://davidwalsh.name/jquery-homepage-mootools">Duplicate the jQuery Homepage Tooltips Using MooTools</a></li><li><a
href="http://davidwalsh.name/sugar/jquery">All jQuery Tutorials</a></li><li><a
href="http://davidwalsh.name/sugar/mootools">All MooTools Tutorials</a></li><li><a
href="http://davidwalsh.name/demos">All MooTools &#038; jQuery Demos</a></li></ul><p>Isn&#8217;t the JavaScript community great?  MooTools FTW!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-podcast">jQuery Podcast &#038; Essential jQuery and MooTools&nbsp;Snippets</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/jquery-link-nudge' rel='bookmark' title='Permanent Link: jQuery Link Nudge&nbsp;Plugin'>jQuery Link Nudge&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/implement-jquery-mootools-event' rel='bookmark' title='Permanent Link: Implementing jQuery-Like Event Syntax in&nbsp;MooTools'>Implementing jQuery-Like Event Syntax in&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/faceoff-show' rel='bookmark' title='Permanent Link: David Walsh on the Faceoff Show&nbsp;Podcast'>David Walsh on the Faceoff Show&nbsp;Podcast</a></li><li><a
href='http://davidwalsh.name/jquery-mootools' rel='bookmark' title='Permanent Link: Using jQuery and MooTools&nbsp;Together'>Using jQuery and MooTools&nbsp;Together</a></li><li><a
href='http://davidwalsh.name/count-mootools-events' rel='bookmark' title='Permanent Link: Count MooTools Events Per Element in MooTools&nbsp;1.2'>Count MooTools Events Per Element in MooTools&nbsp;1.2</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/jquery-podcast/feed</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 143/421 queries in 7.373 seconds using disk

Served from: davidwalsh.name @ 2010-09-02 23:26:39 -->