jQuery support for add-ons

Re: jQuery support for add-ons

by Andrew Lyons -
Number of replies: 2
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

I think it's also worth pointing out that YUI is still the recommended way of doing things for add-ons/plugins in Moodle. This is just to provide a consistent way of doing things for those developers who really really really do not want to use YUI for some reason.

Andrew

Average of ratings: Useful (2)
In reply to Andrew Lyons

Re: jQuery support for add-ons

by Valery Fremaux -
Picture of Plugin developers

Note that many external developpers indeed find YUI (specially YUI3) quite opaque way of programming (including for long time experimented devs big grin, or maybe i'm getting too old for this bulls...t ?). Is there some "essential" documentation that are worth to be read for starting understanding key "way of thinking" in YUI3 for Moodle ?

At this time, i personnaly will continue following integration of "water clear" frameworks such as XHTML plugins and JQuery ajaxisation... till i can penetrate this bush....

Cheers !

In reply to Valery Fremaux

Re: jQuery support for add-ons

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Valery,

Sorry to hear that you find YUI3 so opaque. if you could perhaps indicate which bits you find confusing, we may be able to help further. It took me a little while to get my head around the way in which YUI3 handles things, but once it clicked it made a lot more sense for me and the benefits for Moodle become clearer.

I've been trying to improve the Moodle YUI documentation over the past year or so, but if there's something specific you think we're missing I can put pen to paper and try and clarify things further.

The way in which we now handle YUI (as of Moodle 2.5) is much more similar to the way in which YUI handle YUI and generally the upstream documentation is worth having on tap. The only real things to bear in mind as key differences are:

  • you must write your JS in a YUI module (see the Shifter and Module docs below)
  • our module namespace is moodle-frankenstyle_modname-yuimodulename
  • you must include YUI modules from php using $PAGE->requires->yui_module('moodle-frankenstyle_modname-yuimodulename', 'M.frankenstyle_modname.yuiodulename.initFunction', array(array('a' => 'list', 'of' => 'arguments'));

This is the Moodle-specific documentation:

In terms of upstream documentation, the YUI API is really handy and I find myself delving into it to find and check things daily - http://yuilibrary.com/yui/docs/api/

The YUI user guides (http://yuilibrary.com/yui/docs/guides/) are also very useful, as are the examples which you'll find on the right-hand side in the user guides).

I'd also highly recommend Evan Goer's O'Reilly cookbook. He's provided a three-chapter sample at http://www.goer.org/YUI/ which is also extremely handy.

Hope that this helps, and as I say, if there's anything specific you think we could do with documentation on, I'll try my best to whip something up.

Best wishes and happy New Year,

Andrew

Average of ratings: Useful (2)