mirror of
https://github.com/moodle/moodle.git
synced 2025-07-23 23:31:58 +02:00
javascript MDL-22517 Fix for IE bug with single selects
This commit is contained in:
@@ -333,13 +333,37 @@ M.util.init_maximised_embed = function(Y, id) {
|
||||
* Attach handler to single_select
|
||||
*/
|
||||
M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
|
||||
YUI(M.yui.loader).use('node', function(Y) {
|
||||
Y.on('change', function() {
|
||||
if ((nothing == false && Y.Lang.isBoolean(nothing)) || Y.one('#'+selectid).get('value') != nothing) {
|
||||
Y.one('#'+formid).submit();
|
||||
Y.use('event-key', function() {
|
||||
var select = Y.one('#'+selectid);
|
||||
if (select) {
|
||||
// Try to get the form by id
|
||||
var form = Y.one('#'+formid) || (function(){
|
||||
// Hmmm the form's id may have been overriden by an internal input
|
||||
// with the name id which will KILL IE.
|
||||
// We need to manually iterate at this point because if the case
|
||||
// above is true YUI's ancestor method will also kill IE!
|
||||
var form = select;
|
||||
while (form && form.get('nodeName').toUpperCase() !== 'FORM') {
|
||||
form = form.ancestor();
|
||||
}
|
||||
return form;
|
||||
})();
|
||||
// Make sure we have the form
|
||||
if (form) {
|
||||
// Create a function to handle our change event
|
||||
var processchange = function(e, lastindex) {
|
||||
if ((nothing===false || select.get('value') != nothing) && lastindex != select.get('selectedIndex')) {
|
||||
this.submit();
|
||||
}
|
||||
}
|
||||
// Attach the change event to the keypress, blur, and click actions.
|
||||
// We don't use the change event because IE fires it on every arrow up/down
|
||||
// event.... usability
|
||||
Y.on('key', processchange, select, 'press:13', form, select.get('selectedIndex'));
|
||||
select.on('blur', processchange, form, select.get('selectedIndex'));
|
||||
select.on('click', processchange, form, select.get('selectedIndex'));
|
||||
}
|
||||
}
|
||||
},
|
||||
'#'+selectid);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -349,9 +373,9 @@ M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
|
||||
M.util.init_url_select = function(Y, formid, selectid, nothing) {
|
||||
YUI(M.yui.loader).use('node', function(Y) {
|
||||
Y.on('change', function() {
|
||||
if ((nothing == false && Y.Lang.isBoolean(nothing)) || Y.one('#'+selectid).get('value') != nothing) {
|
||||
window.location = M.cfg.wwwroot+Y.one('#'+selectid).get('value');
|
||||
}
|
||||
if ((nothing == false && Y.Lang.isBoolean(nothing)) || Y.one('#'+selectid).get('value') != nothing) {
|
||||
window.location = M.cfg.wwwroot+Y.one('#'+selectid).get('value');
|
||||
}
|
||||
},
|
||||
'#'+selectid);
|
||||
});
|
||||
|
Reference in New Issue
Block a user