|
|
|
@ -22,6 +22,44 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
$("#id_tipo, #id_ano").change(recuperar_numero_ano); |
|
|
|
|
|
|
|
function compare(a, b) { |
|
|
|
if (a.text < b.text) |
|
|
|
return -1; |
|
|
|
if (a.text > b.text) |
|
|
|
return 1; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
|
$("#id_tipo_autor").change(function() { |
|
|
|
var tipo_selecionado = $("#id_tipo_autor").val(); |
|
|
|
var autor_selecionado = $("#id_autor").val(); |
|
|
|
$("#id_autor option").remove() |
|
|
|
if (tipo_selecionado !== undefined && tipo_selecionado !== null) { |
|
|
|
var json_data = { |
|
|
|
tipo : tipo_selecionado, |
|
|
|
data_relativa : $("#id_data_apresentacao").val() |
|
|
|
} |
|
|
|
$.getJSON("/api/autor/possiveis", json_data, function(data){ |
|
|
|
if (data) { |
|
|
|
var results = data.sort(compare); |
|
|
|
if (results.length > 1) { |
|
|
|
$("#id_autor").append("<option>-----</option>"); |
|
|
|
} |
|
|
|
$.each(results, function(idx, obj) { |
|
|
|
$("#id_autor") |
|
|
|
.append($("<option></option>") |
|
|
|
.attr("value", obj.value) |
|
|
|
.text(obj.text)); |
|
|
|
}); |
|
|
|
$("#id_autor").val(autor_selecionado); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
$("#id_tipo_autor").trigger('change'); |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|
|
|
|
{% endblock %} |
|
|
|
|