Skip to content
Snippets Groups Projects
Forked from it-lab / grade
Source project has a limited visibility.
index.js 2.38 KiB
$(function()
{
    $("#facultySelect [value='0']").attr('selected', 'selected');
    $('#departmentSelect').attr('disabled', 'disabled');
    $("#departmentSelect [value='0']").attr('selected', 'selected');

    // Переключение страниц
    $('body').on('click', '.paginatorLink', function(){
        $('.paginatorPage').addClass('hiddenPage');
        $('.paginator_item').removeClass('selectedPageNum');
        $('#'+this.id).removeClass('hiddenPage');
        $(this).children('.paginator_item').addClass('selectedPageNum');
    });    
    
    // Выбор факультета
    $('#facultySelect').change(function(){
        if (($('#facultySelect option:selected').val()!= '0')) {

                $("#search_results").html('<div class="search_load"><img src="' + URLdir + 'media/img/load.gif"/></div>');
                $("#departmentSelect").html('<option value="0">--- Кафедра ---</option>');
                $('#departmentSelect').attr('disabled', 'disabled');
                $.post(URLdir + 'handler/admTeachers/getTeachersList', {'facultyID': $('#facultySelect option:selected').val(), 'departmentID': '0'}, function(data){
                    $("#search_results").html(data);
                });
                $.post(URLdir + 'handler/admTeachers/getDepartmentsList', {'facultyID': $('#facultySelect option:selected').val()}, function(data){
                    $.each(data, function(i){
                        var dep = data[i];
                        if (!dep.Name) dep.Name = 'Служебная кафедра';
                        $("#departmentSelect").append('<option value="'+dep.ID+'">'+dep.Name+'</option>');
                    });
                    $("#departmentSelect").removeAttr("disabled");
                }, "json");
        }
        else
        {
                $('#departmentSelect').attr('disabled', 'disabled');
        }
    });

    // Выбор кафедры
    $('#departmentSelect').change(function(){
        $("#search_results").html('<div class="search_load"><img src="' + URLdir + 'media/img/load.gif"/></div>');
        if (($('#departmentSelect option:selected').val()!= '0')) {
                $.post(URLdir + 'handler/admTeachers/getTeachersList', {'facultyID': '0', 'departmentID': $('#departmentSelect option:selected').val()}, function(data){
                        $("#search_results").html(data);
                });
        }
    });
});