Curso.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(function($){
$(document).ready(function(){
var $instituicaoField = getElementFor('instituicao');
var $escolaField = getElementFor('escola');
var $cursoField = getElementFor('curso');
var handleGetCursos = function(response) {
var selectOptions = jsonResourcesToSelectOptions(response['options']);
updateSelect($cursoField, selectOptions, "Selecione um curso");
}
var updateCursos = function(){
resetSelect($cursoField);
if ($instituicaoField.val() && $escolaField.val() && $escolaField.is(':enabled')) {
$cursoField.children().first().html('Aguarde carregando...');
var urlForGetCursos = getResourceUrlBuilder.buildUrl('/module/DynamicInput/Curso', 'cursos', {
escola_id : $escolaField.attr('value'),
instituicao_id : $instituicaoField.attr('value'),
});
var options = {
url : urlForGetCursos,
dataType : 'json',
success : handleGetCursos
};
getResources(options);
}
$cursoField.change();
};
// bind onchange event
$escolaField.change(updateCursos);
}); // ready
})(jQuery);