Getting Started With Moodle Java Script Coding
|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.
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.
- YUI combo loading - you probably want to turn this off so that files are not combined.
- 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
- How to create a YUI 3 module describes how to create a 'static module' which is also described in the guidelines above and also how to create a more advanced 'YUI 3 Moodle Module'
- There are a couple of interesting FAQ pages :