Moodle

disabledif doesn't work in IE 7

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.9.4
  • Fix Version/s: 1.9.5
  • Component/s: Forms Library
  • Labels:
    None
  • Environment:
    Moodle 1.9.4+ (Build: 20090325)
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Steps to reproduce:
1. Run IE 7.
2. Add grade item on Edit categories and items page.
3. Select for Grade type option "Scale"
Field "Scale" doesn't enable. Fields "Maximum grade" and "Minimum grades" doesn't disable.

Revert javascript-static.js to previous version helps. Seems as regression from MDL-18522.

Issue Links

Activity

Hide
Tim Hunt added a comment -

The fix for MDL-15827 is the other possible cause for this regression.

I'm going to leave this for a day or too in case a GSOC applicant wants to fix it, otherwise I will have to try to fix it myself before the next weekly.

Show
Tim Hunt added a comment - The fix for MDL-15827 is the other possible cause for this regression. I'm going to leave this for a day or too in case a GSOC applicant wants to fix it, otherwise I will have to try to fix it myself before the next weekly.
Hide
Sehrish Abdul Malik added a comment -

I was tracking down the bug and found its is reproducible in IE7,
working fine on firefox 3.0.8
but not working on Opera 9.6.3.
when we choose Edit categories and item page from action dropdown menu the respective pages doesn't show up in case of Opera.

Howeven for IE7, i have found:

1. /moodle/grade/edit/tree/item.php uses $mform object of type edit_item_form and calls its display method.
2. edit_item_form generates all the html code and hooks different javascript methods.
3. lockoptionsall() method in /moodle/lib/javascript-static.js actually enable disable all fields assosiated with form and in case of firefox it is working and but not in IE7's case.
4. seems like there is some bug in IE7, I googled it and found this link http://11heavens.com/IE7-bug-report-onclick-event-handler.

For the time being i am still working on the bug and trying to find out a descent fix. But i would appreciate if i could get some hints on this

Show
Sehrish Abdul Malik added a comment - I was tracking down the bug and found its is reproducible in IE7, working fine on firefox 3.0.8 but not working on Opera 9.6.3. when we choose Edit categories and item page from action dropdown menu the respective pages doesn't show up in case of Opera. Howeven for IE7, i have found: 1. /moodle/grade/edit/tree/item.php uses $mform object of type edit_item_form and calls its display method. 2. edit_item_form generates all the html code and hooks different javascript methods. 3. lockoptionsall() method in /moodle/lib/javascript-static.js actually enable disable all fields assosiated with form and in case of firefox it is working and but not in IE7's case. 4. seems like there is some bug in IE7, I googled it and found this link http://11heavens.com/IE7-bug-report-onclick-event-handler. For the time being i am still working on the bug and trying to find out a descent fix. But i would appreciate if i could get some hints on this
Hide
Sehrish Abdul Malik added a comment -

After my investigation over the bug it seems to be a bug in microsoft IE7. The browser is not currently supporting the onclick, onblur, onchange handlers on the DOM option elements. As a proof of concept here is an html code to test on both IE7 and FF1+:

<html>
<head>

<script>
window.onload = function(){
document.getElementById('optA').onclick = function() {alert('Event handler hook called...')};
}
</script>

</head>
<body>
<select id="selBox" name="bakwas">
<option id="optA" value="1">Option A</option>
<option id="optB" value="2">Option B</option>
</select>
</body>
</html>

The code gave me no alert when I clicked option A in IE7 but that alert appeared when I did the same action in Firefox. Check it out!

Show
Sehrish Abdul Malik added a comment - After my investigation over the bug it seems to be a bug in microsoft IE7. The browser is not currently supporting the onclick, onblur, onchange handlers on the DOM option elements. As a proof of concept here is an html code to test on both IE7 and FF1+: <html> <head> <script> window.onload = function(){ document.getElementById('optA').onclick = function() {alert('Event handler hook called...')}; } </script> </head> <body> <select id="selBox" name="bakwas"> <option id="optA" value="1">Option A</option> <option id="optB" value="2">Option B</option> </select> </body> </html> The code gave me no alert when I clicked option A in IE7 but that alert appeared when I did the same action in Firefox. Check it out!
Hide
Sehrish Abdul Malik added a comment -

correct me if i am wrong this bug cannot be fixed without major changes in the code.

Show
Sehrish Abdul Malik added a comment - correct me if i am wrong this bug cannot be fixed without major changes in the code.
Hide
Tim Hunt added a comment -

Yes, but we need to fix it. Does it work if we switch to using the YUI events library to add the even handlers?

Show
Tim Hunt added a comment - Yes, but we need to fix it. Does it work if we switch to using the YUI events library to add the even handlers?
Hide
Ryan Smith added a comment -

Just an FYI from MDL-18779.... this bug occurs in IE6, IE7, and IE8.

Show
Ryan Smith added a comment - Just an FYI from MDL-18779.... this bug occurs in IE6, IE7, and IE8.
Hide
Sehrish Abdul Malik added a comment -

I hooked an option tag with YUI event utilities and tested the same code i pasted earlier .... its once again working on firefox but not on IE7

Show
Sehrish Abdul Malik added a comment - I hooked an option tag with YUI event utilities and tested the same code i pasted earlier .... its once again working on firefox but not on IE7
Hide
Tim Hunt added a comment -

Note that this works in most cases. For example all the enable disable on the quiz settings page works.

So, as Sehrish found, the problem seems to be when the source element is a Dropdown menu, the event handler does not fire.

OK. The problem is that in Internet Exporer, if select is a HTML select element, then select[0] is the first option element inside it. So my test for whether form[dependon] was a single element, or array of elements (radio buttons), was broken.

I was doing if (!masters[0]). Now I will try if (masters.tagName)

Doh! I was already using the .tagName test everywhere else.

OK, fix checked in.

Show
Tim Hunt added a comment - Note that this works in most cases. For example all the enable disable on the quiz settings page works. So, as Sehrish found, the problem seems to be when the source element is a Dropdown menu, the event handler does not fire. OK. The problem is that in Internet Exporer, if select is a HTML select element, then select[0] is the first option element inside it. So my test for whether form[dependon] was a single element, or array of elements (radio buttons), was broken. I was doing if (!masters[0]). Now I will try if (masters.tagName) Doh! I was already using the .tagName test everywhere else. OK, fix checked in.
Hide
Petr Škoda (skodak) added a comment -

yay!
thanks

Show
Petr Škoda (skodak) added a comment - yay! thanks
Hide
Nicolas Connault added a comment -

Tested: works fine! Thanks.

Show
Nicolas Connault added a comment - Tested: works fine! Thanks.

People

Dates

  • Created:
    Updated:
    Resolved: