mirror of
https://github.com/moodle/moodle.git
synced 2025-07-24 07:41:40 +02:00
MDL-21577 converting select auto submit code
This commit is contained in:
@@ -384,7 +384,7 @@ M.util.init_maximised_embed = function(Y, id) {
|
||||
/**
|
||||
* Attach handler to single_select
|
||||
*/
|
||||
M.util.init_single_select = function(Y, formid, selectid, nothing) {
|
||||
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) {
|
||||
@@ -655,39 +655,6 @@ function lockoptionsallsetup(formid) {
|
||||
return lockoptionsall(formid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function mainly for drop-down menus' onchange events,
|
||||
* submits the form designated by args.id.
|
||||
* Example usage of the html_select component with this function:
|
||||
* <pre>
|
||||
* $select = new html_select();
|
||||
* $select->options = array('delete' => get_string('delete'));
|
||||
* $select->name = 'action';
|
||||
* $select->button->label = get_string('withselected', 'quiz');
|
||||
* $select->id = 'menuaction';
|
||||
* $select->add_action('change', 'submit_form_by_id', array('id' => 'attemptsform', 'selectid' => 'menuaction'));
|
||||
* echo $OUTPUT->select($select);
|
||||
* </pre>
|
||||
*/
|
||||
function submit_form_by_id(e, args) {
|
||||
var theform = document.getElementById(args.id);
|
||||
if (!theform) {
|
||||
return false;
|
||||
}
|
||||
if (theform.tagName.toLowerCase() != 'form') {
|
||||
return false;
|
||||
}
|
||||
//MDL-21513 the below makes the first option unselectable assuming it will be some sort
|
||||
//of "Choose..." option. However if there is no placeholder first option the first item is unselectable :(
|
||||
//if (args.selectid) {
|
||||
// var select = document.getElementById(args.selectid);
|
||||
//if (select.selectedIndex == 0) {
|
||||
// return false;
|
||||
//}
|
||||
//}
|
||||
return theform.submit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Either check, or uncheck, all checkboxes inside the element with id is
|
||||
* @param id the id of the container
|
||||
@@ -1459,10 +1426,6 @@ function frame_breakout(e, properties) {
|
||||
// DO NOT USE!!!!!!!
|
||||
// Do not put this stuff in separate file because it only adds extra load on servers!
|
||||
|
||||
function submitFormById(id) {
|
||||
submit_form_by_id(null, {id: id});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in a couple of modules to hide navigation areas when using AJAX
|
||||
*/
|
||||
|
Reference in New Issue
Block a user