From 676268d7f458702ee85806a3fb4db43531e3cee3 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 17 Jun 2024 16:25:40 +0000 Subject: [PATCH] refactor(cantusindex): add comment for dal option selector --- django/cantusdb_project/main_app/templates/ci_search.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django/cantusdb_project/main_app/templates/ci_search.html b/django/cantusdb_project/main_app/templates/ci_search.html index 8ad58281b..8ea28d1ba 100644 --- a/django/cantusdb_project/main_app/templates/ci_search.html +++ b/django/cantusdb_project/main_app/templates/ci_search.html @@ -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'); } }