Child pages
  • Using addJquery(), addJqueryPlugin() and addJqueryUI()

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

If you wish to use a newer or older version of jQuery, you just have to pass the version number as first parameter:

Code Block

Controller::addJquery('1.3.1');

...

Tip
titleMaking noConflict work

Version 1.3.1 of jQuery is not available through $, but rather using the $j131 variable.

Hence, you can call $j131('body').hide();.

If you wish to use 1.3.1's $, you simply have to use this:

Code Block

<script type="text/javascript">
var tmp$tmp = $;     // jQuery's current version becomes en temporary variable.
$ = $j131;
$('body').hide(); // Now using 1.3.1's hide().
$ = tmp;          // IMPORTANT: always restore the default version of jQuery!
</script>

If the file is on your server, you can give its path as a second argument:

Code Block

Controller::addJquery('1.3.1', '/local/path/to/jquery');

...

For instance, if you need to use jQuery's slider:

Code Block

public function setMedia('ui.slider')
{
    $this->addJquery>addJqueryUI('ui.slider');
}

This code will automatically include the following dependencies:

Code Block
languagehtml/xml

<script type="text/javascript" src="/trunk/js/jquery/ui/ui.core.min.js"></script>
<script type="text/javascript" src="/trunk/js/jquery/ui/ui.widget.min.js"></script>
<script type="text/javascript" src="/trunk/js/jquery/ui/ui.mouse.min.js"></script>
<script type="text/javascript" src="/trunk/js/jquery/ui/ui.slider.min.js"></script>

...