Created
April 25, 2013 12:17
-
-
Save romulostorel/5459270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
$("input[id$=academic_year_id], input[id$=school_id]").bind('change', generateAcademicClassroomSelect); | |
var option = _.template("<option value='<%=id%>'><%=label%></option>"); | |
function generateAcademicClassroomSelect(){ | |
$("select[id$=academic_classroom]").empty(); | |
var academic_year_id = $("input[id$=academic_year_id]").val(); | |
var school_id = $("input[id$=school_id]").val() | |
$.getJSON(Router.academic_classrooms_path({ school_id: school_id, academic_year_id: academic_year_id }), function(data) { | |
$.each(data, function(key, value ) { | |
$("select[id$=academic_classroom]").append(option({id: value.id, label: value.label})) | |
}); | |
}); | |
generateAcademicClassroomEvaluationDisciplineSelect(); | |
} | |
function generateAcademicClassroomEvaluationDisciplineSelect(){ | |
$("select[id$=academic_classroom_evaluation_discipline]").empty(); | |
var academic_classroom_id = $('select[id$=academic_classroom]').val(); | |
console.log(academic_classroom_id); | |
$.getJSON(Router.academic_classroom_evaluation_discipline_path({ academic_classroom_id: academic_classroom_id }), function(data) { | |
$.each(data, function(key, value ) { | |
$("select[id$=academic_classroom_evaluation_discipline]").append(option({id: value.id, label: value.label})) | |
}); | |
}); | |
} | |
generateAcademicClassroomSelect(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment