Getting Started With Moodle Java Script Coding

Revision as of 14:49, 3 January 2014 by Andrew Nicols (talk | contribs)

Jump to: navigation, search
Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.
Please note that much of this documentation is obsolete. A replacement is available in YUI.

This is meant to be a page for helping beginners to using JS and YUI 2 / 3 in Moodle.

Moodle Settings for Javascript Development

The following settings will ensure that the js loaded by your browser is relatively readable.

Make sure that :

  • your Development / Debugging / Debug messages is set to "Developer : Extra Debug Moodle Messages ...." - Moodle will then use the debug non-minified and thus more readable YUI 2 and YUI 3 library files.
  • You will probably want to change some of the settings at "Home / Site administration / Appearance / AJAX and Javascript" :
    • YUI combo loading - you probably want to turn this off so that files are not combined.
    • Javascript caching and compressing - turn this off so that your custom JS code is not minified.
    • Check the other settings on this page to see that they are as you would expect them to be.

Use Firebug or the Built in Chrome Developer Tools

Once the js code that you load into the browser is a little more readable you can now use the excellent debugging tool built into Chrome, the Firebug extension available for FF or Firebug lite for IE.

These tools allow you to set breakpoints in js code examine variable and to use commands in your js such as console.log() which can give you a treeview of the contents of the contents of any object that you send it.

Support for JS in Your PHP Editor

Am not sure if there is the possibility to get context sensitive help or to be able to jump to declaration of classes, methods etc in PHP editors such as Eclipse, Zend IDE etc.

Documentation on the Use of JS in Moodle