Dear moodle, can we improve those fragile js hooks in core?

Dear moodle, can we improve those fragile js hooks in core?

by Stuart Lamour -
Number of replies: 2
Picture of Plugin developers

Hi All,

when your making a theme in moodle its more than likely you'll be using :

echo $OUTPUT->course_content_header();
echo $OUTPUT->main_content();
echo $OUTPUT->course_content_footer();

The stuff around that is generally what you change, and that makes it really easy to break js....

 

For example :

echo $OUTPUT->course_content_header();
echo $OUTPUT->main_content();
echo $OUTPUT->course_content_footer();

currently spits out something like :

<div class="course-content"> {stuff} </div>

but nothing with #region-main, #page-content, #page etc -  which are examples of actual hook used by the javascript in core, and can be really easily changed in a theme.

 

For core js like drag n drop and whatever else would it be sensible to suggest the hooks :

e.g.

REGIONMAIN : 'some element identifier'

were always hooks that were actually the stuff spat out by those core output renderers?

 

I'm not in any way suggesting wrapping more and more divs around content generated by core output renderers, just that it might be less fragile if the hooks used by core js were the same as those output by core renderers, rather than those you can easily change in a theme.

 

As always, thoughts welcome.

Average of ratings: -
In reply to Stuart Lamour

Re: Can we improve those fragile js hooks in core?

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 Stuart,

This has already been addressed for 2.7 on most common/recent JS components by MDL-35423.

I have also started rewriting the drag and drop upload in MDL-33057 and this will incorporate a similar change there too.

These changes are unlikely to be backported.

Cheers,

Andrew

Average of ratings:Useful (1)