OVERVIEW Drupal 5.0 will include the fab JavaScript library jQuery. But where does that leave us poor slobs who need to develop on 4.7? Out in the cold, that's where. Sadly, Drupal 4.7's own JavaScript package conflicts with jQuery in a number of places, preventing easy including of the jQuery library in contributed modules. Enter jquery47, a slightly hacked version of jQuery, compatible with Drupal's own JS files. By invoking jquery47_add_js('path/to/your/file.js') you can reap the benefits of jQuery while wrapped warmly in the bosom of Drupal 4.7 USING First, a note: the make jQuery compatible with Drupal, I had to rename the $ function to JQ. Sorry, there's really no way around this. When Drupal 5.0 comes out, you'll have to rename all your calls to JQ('...') to $('...'). This also applies to the $ object. So calls to $.get(...) or $.post(...) will also need to be renamed JQ.get(...) or JQ.post(...) Write your JS file and put it somewhere. Using drupal_get_path() get your file's path. Call jquery47_add_js($yourfilepath) and you're ready to go. CONTENTS * Jquery47.module In addition to the jquery47.module, there is also two versions of the modified jQuery library. The normal human readable version for you to see what crimes I committed agains the jQuery library, and a compressed version to save you bandwidth $$$. * Pageax.module The pageax module is an add-on to jquery47 that makes fetching pages from Drupal via Asyncronous JavaScript over XML (AJAX) an easier process. If the data you want to fetch appears on its own URL, you can simply use pageax to fetch it for you (without side bars, breadcrumbs, headers, or other page cruft) simply and easily. Pageax requires you write your own .js file like this example: if (isJsEnabled()) { addLoadEvent(myinitfunc); } function myinitfunc() { JQ("div#linkcontainer a").pageax(JQ("div#content-container")); } // EOF Where the div#linkcontainer is just a jQuery search to find the links you wish to attach this behavior too and div#content-container is where the content should be placed when it has been fetched. Some possible uses include fetching image nodes from a slide show, paging through content, etc. EPILOGUE This module will be deprecated in Drupal 5.0 (thank god). Use at your own risk until then. I will probably release a pageax project to bring this functionality to Drupal 5. Hopefully, it will get into drupal 6. AUTHOR Mark Fredrickson mark@advantagelabs.com
"git@git.drupal.org:project/drupal.git" did not exist on "eea53076d9471e360f318819f117f33dfdf5bd42"
Select Git revision
drupal
-
-
- Open in your IDE
- Download source code
Name | Last commit | Last update |
---|---|---|
README.txt | ||
jquery-modified-compressed.js | ||
jquery-modified.js | ||
jquery47.module | ||
loading.gif | ||
pageax.js | ||
pageax.module |