I cannot tell you how many times I’ve walked into a project that required the following:
- Fancy JavaScript alerts, dialogs, and validation.
- JavaScript assets that will distributed to subsites / satellite sites.
- Of these sites, some may or may not already have these assets already defined.
What I’m referring to specifically is jQuery. While building a tasty and user-friendly form.. I needed a way to check to see if jQuery didn’t exist, and if it didn’t include it dynamically by append it to the HEAD tag. This is commonly referred to ‘including jQuery dynamically’. Often times different phrases such as ‘check to see if jQuery is defined’, ‘lazy load jQuery’, ‘!window.jQuery’
Here is the JavaScript code to make the magic happen.
if(!(window.jQuery && window.jQuery.fn.jquery == '1.3.2')) {var s = document.createElement('script');s.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js');s.setAttribute('type', 'text/javascript');document.getElementsByTagName('head')[0].appendChild(s);}
As a recap, here is what the snippet above does. “Check to see if jQuery is defined. If it’s not, grab jQuery from Google’s API and include it in the HEAD tag”.
XZero Scripts has released a great tool for developer looking for a classified script – XZero Community Classifieds.
With an strong and eager community helping to further the development of the script, many people have taken the liberty to release their own mods. One modification we thought would be awesome to give back to the community is the expanding drop-down city list in the right side bar. Interested? Great!
You’re probably asking yourself “what’s the catch”? Truth be told, just a simple 1 file replacement. Follow these steps:
Installation
- Open ‘cities.inc.zip’ and extract the file ‘cities.inc.php’ to your computer / desktop.
- Open your favorite FTP program and upload ‘cities.inc.php’ to the root of your XZero Classifieds installation. This WILL replace the old ‘cities.inc.php’ that came packaged with your original installation.
That’s it!
Enjoy!
Developer Notes
The drop down uses the jQuery framework for its animations. The framework is being remotely downloaded using Google’s JavaScript API script (jsapi).
Download Free jQuery Cities Drop down Mod for XZero Classifieds (1.51kb)
Downloaded 275 times.
As we all know Google has released some pretty nifty things in the past. Today, we’re going to look at one of its most delightful additions for web developers. Google AJAX API.
What is Google AJAX API?
Google’s AJAX APIs let you implement rich, dynamic web sites entirely in JavaScript and HTML. You can add a map to your site, a dynamic search box, or download feeds with just a few lines of JavaScript. Read the rest of this entry »
Tags:
google ajax,
google ajax api,
google and jquery,
google api,
google.load(),
jQuery,
jquery bandwidth,
jquery integration Posted in
Google,
Tutorials,
XHTML,
jQuery |
4 Comments »
Recent Comments