$(document).ready(function(){ $('.class_setting_block input[type="reset"]').off('click').on('click',function(){ $('.col_input').val(''); }); $('.class_setting_block input[type="submit"]').off('click').on('click',function(){ var class_number_range = []; class_number_range.push(Number($('.class_setting_block .col_input[name="MinClass"]').val())); class_number_range.push(Number($('.class_setting_block .col_input[name="MaxClass"]').val())); var enrollment_available = $('.class_setting_block .col_input#Person').val(); class_number_range.sort(); var params_array = (window.location.search.substring(1)=="") ? [] : window.location.search.substring(1).split('&').map(function(el){return el.split('=')}); var params = {}; params_array.forEach(function(el){params[el[0]] = el[1]}); var params_to_send = {'type':'class_setting','class_number_range':class_number_range,'enrollment_available':enrollment_available}; params_to_send = Object.assign(params,params_to_send); var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send); post_data.done(function(){ window.location.search=""; }); }); $('.fieldset_block input[type="submit"]').click(function(){ $el = $('.fieldset_block li.required'); for(var i = 0; i< $el.length ; i++){ if($el.eq(i).siblings('.col_r').find('.required').val() == ""){ $el.eq(i).addClass('errFld'); if($el.eq(i).siblings('.col_r').find('.errMsg').length == 0) $el.eq(i).siblings('.col_r').append('
'+((I18n.locale == "en") ? 'Required field': '必填欄位')+'
'); }else{ $el.eq(i).removeClass('errFld'); $el.eq(i).siblings('.col_r').find('.errMsg').remove(); }; }; if($('.fieldset_block .required.errFld').length != 0) return false; else return true; }) var $el = $('.fieldset_block select'); for(var i = 0 ; i < $el.length ; i++) if($el.eq(i).attr('value') != "" && $el.eq(i).attr('value') != undefined) $el.eq(i).find('option[value='+$el.eq(i).attr('value')+']').attr('selected','selected'); try{CKEDITOR.replaceAll()}catch(e){console.log(e)}; });