Question about Moodle Javascript in mod_assign

Question about Moodle Javascript in mod_assign

by Stephen Bourget -
Number of replies: 2
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Moodlers,

I'm currently trying to work out a Moodle bug (MDL-56022) and have stumbled across a minor Issue that I need help solving.  I've added a new element to an mform in the assignment module which has some sort of javascript auto-submit.  (When you make changes to any element in that form, it the form is automatically submitted and the page is reloaded.)  I cannot seem to figure out how to apply the same auto submit to my newly added form element. (If I turn Javascript off in my browser and view the page I get a submit button, so I can confirm that the code I have works otherwise)

My code is here: https://github.com/moodle/moodle/compare/master...sbourget:MDL-56022_m32v1?expand=1#diff-4ab0edc0983df466624d0483b075249cR90 and any help or guidance would be appreciated, as I'm not entirely sure where I should be looking to fix this.

Thanks!

Average of ratings: Useful (1)
In reply to Stephen Bourget

Re: Question about Moodle Javascript in mod_assign

by Matt McDermott -
The auto submit feature on this page is implemented with unique change listeners applied to each element. To make this work you'll need to add a change listener for the checkbox that you added.


Here is an example on what you'll need to add to mod/assign/module.js:

var downloadasfolderselement = Y.one('#id_downloadasfolders');
if (downloadasfolderselement) {
downloadasfolderselement.on('change', function(e) {
Y.one('form.gradingoptionsform').submit();
});
}

It should be included in the M.mod_assign.init_grading_options function.

Average of ratings: Useful (2)
In reply to Matt McDermott

Re: Question about Moodle Javascript in mod_assign

by Stephen Bourget -
Picture of Core developers Picture of Plugin developers Picture of Testers

Thank You!

That was exactly what I was looking for