Skip to content

Commit

Permalink
refactor(cantusindex): add comment for dal option selector
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmarchd01 committed Jun 17, 2024
1 parent f7755c2 commit 676268d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion django/cantusdb_project/main_app/templates/ci_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
var genreID = genreObj ? genreObj.id : null;

opener.document.getElementById('id_cantus_id').value = cantus_id;
// Since we're using a django-autocomplete-light widget for the Genre selector,
// we need to follow a special process in selecting a value from the widget:
// Set the value, creating a new option if necessary
if (genreID) {
if (opener.$('#id_genre').find("option[value='" + genreID + "']").length) {
opener.$('#id_genre').val(genreID).trigger('change');
} else {
// Create a new DOM Option and pre-select it by default
var newOption = new Option(genre, genreID, true, true);
// Append it to the select and trigger change
opener.$('#id_genre').append(newOption).trigger('change');
}
}
Expand Down

0 comments on commit 676268d

Please sign in to comment.