Book Image

Learning Joomla! 1.5 Extension Development

Book Image

Learning Joomla! 1.5 Extension Development

Overview of this book

Table of Contents (17 chapters)
Learning Joomla! 1.5 Extension Development
Credits
About the Author
About the Reviewer
Preface

Using jQuery


Another popular JavaScript framework is jQuery. The jQuery framework has functionality that is similar to MooTools, but uses a different style of code. Although they are separate projects, extra care must be taken when using them together. By default, both frameworks automatically reserve $ to have a special meaning in JavaScript. If you do not take steps to avoid this behavior, one library will overwrite the other's assignments and the scripts will fail.

Fortunately, jQuery has strategies that you can use to avoid this conflict. There are three things that you must do to keep jQuery and MooTools out of each other's way:

  • Load jQuery only after MooTools has been loaded

  • Call jQuery.noConflict() to return control of $ to MooTools

  • Reference jQuery directly in your scripts instead of using $

Writing jQuery code

Before avoiding conflicts with MooTools, start by writing some jQuery without MooTools being present. First, go to jquery.com, download the latest version of jQuery...