Wednesday 4 November 2015

Moodle: Avoid alert message when form changed and exit page

Hello,

Sometimes in a moodleform you want to move to another page by javascript and a message appears saying "Are you sure...?"

The solution:

In your javascript code, use before call window.location:

window.onbeforeunload = null; 

Best regards!

UPDATE 09/3/2015
P.D: Another option is editing the form and in the definition function add:

public function definition() {
        $mform =& $this->_form;
        $mform->disable_form_change_checker();