Oracle Magazine Special offer for AjaxImpact.com Visitors!! Subscribe to Oracle Magazine for Free!
AJAX IMPACT


ARTICLES
Creating Your Own $
05/01/2009, by Neil Roberts



The bling, one of the best global variables in JavaScript. A tool which has come to mean, as a function, a way to locate a node or set of nodes. And, as a namespace, a simple way to access often-used functionality. “This can’t be done with Dojo,” you insist. But you’re wrong, it’s really easy. The ideas behind this little symbol are quite simple and I’m going to show you how to create your own customized version of it.

I’m going to look to jQuery for inspiration. Its fanbase is huge, its fans declare its syntax beautiful and expressive, and its “plugin” syntax is easy to use.

Your first decision is how you want to start your $ off. dojo.query will give us our node-locating abilities. Do you want it to support jQuery’s plugin syntax? Do you want it to contain all of the functions and properties of the normal dojo object?

The second decision is a little trickier. If the dojo object is updated during the life of your page, do you want the changes from the dojo object to make it into your $. This would generally happen after a dojo.require statement (which imports new code). Something like a dojo.require("dojo.behavior"); call that adds the behavior field to the dojo object. Another situation, though less likely, is that one of the properties on the dojo object might change. The tradeoff depends on whether or not you plan on overriding any of the fields that exist in the dojo object. If updates to dojo go from dojo to $, it means updates to $ go from $ to dojo.

   Read More...

 Rate this Ajax Articles
 Rating: 10.0 out of 1 vote cast

AJAX NEWS
05/15/2009 A tutorial on Prototype, Google Maps API and the HeatMapAPI
05/15/2009 The World's Most Popular Programming Language Has Fashion and Luck to Thank
05/09/2009 Cross-Browser Widgets
05/08/2009 Monadic parser library for JavaScript
05/05/2009 They Shoot Browsers, Don’t They?
05/01/2009 Feature Detection: State of the Art Browser Scripting


INDUSTRY NEWS
05/19/2006 Ajax grabs center stage at JavaOne, By Tony Baer
05/15/2006 Oracle to boost AJAX, Java , By Paul Krill
05/13/2006 Open AJAX Group Drafts Development Plans, By Stacy Cowley
05/13/2006 AJAX Powers Interactive Marketing ASP, By AjaxWorld News Desk
05/12/2006 AJAX Experts Tackle Security, Other Issues , By Darryl K. Taft
05/11/2006 Adobe Releases Spry Framework for AJAX, By AjaxWorld News Desk
More 
       

      © 2008 ajaximpact.com. All rights reserved.