Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

jQuery: Difference between revisions

From MoodleDocs
No edit summary
Line 15: Line 15:


<code php>
<code php>
// inside file: /theme/sometheme/lib.php file
<?php
// file: /theme/sometheme/lib.php file
function theme_sometheme_page_init($page) {
function theme_sometheme_page_init($page) {
     $page->requires->jquery();
     $page->requires->jquery();

Revision as of 14:34, 19 March 2013

Moodle 2.5


WORK IN PROGRESS

YUI is the recommended library for development of Moodle plugins or customisations. However due to significant demand it will be possible to use also jQuery in Moodle 2.5 and later.


Examples

Basic jQuery in custom theme

  1. create /theme/sometheme/lib.php file if it does not exist yet
  2. add new function theme_sometheme_page_init to the lib.php file (replace 'sometheme' with real name of your theme)
  3. use jQuery in theme layout files

<?php // file: /theme/sometheme/lib.php file function theme_sometheme_page_init($page) {

   $page->requires->jquery();

}

Basic jQuery in activity module