|
@ -5,6 +5,15 @@ |
|
|
|
|
|
|
|
|
{% block extra_js %} |
|
|
{% block extra_js %} |
|
|
<script language="Javascript"> |
|
|
<script language="Javascript"> |
|
|
|
|
|
|
|
|
|
|
|
function compare(a, b) { |
|
|
|
|
|
if (a.text < b.text) |
|
|
|
|
|
return -1; |
|
|
|
|
|
if (a.text > b.text) |
|
|
|
|
|
return 1; |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
$(document).ready(function() { |
|
|
$("#id_tipo_autor").change(function() { |
|
|
$("#id_tipo_autor").change(function() { |
|
|
$("#id_autor option").remove() |
|
|
$("#id_autor option").remove() |
|
@ -12,7 +21,7 @@ |
|
|
if (selected !== undefined && selected !== null) { |
|
|
if (selected !== undefined && selected !== null) { |
|
|
$.getJSON("/api/autor?tipo=" + selected, function(data){ |
|
|
$.getJSON("/api/autor?tipo=" + selected, function(data){ |
|
|
if (data) { |
|
|
if (data) { |
|
|
var results = data.results; |
|
|
var results = data.results.sort(compare); |
|
|
if (results.length > 1) { |
|
|
if (results.length > 1) { |
|
|
$("#id_autor").append("<option>-----</option>"); |
|
|
$("#id_autor").append("<option>-----</option>"); |
|
|
} |
|
|
} |
|
|