diff --git a/app/assets/javascripts/projects.js b/app/assets/javascripts/projects.js index b2db6ea..6bf8ab9 100644 --- a/app/assets/javascripts/projects.js +++ b/app/assets/javascripts/projects.js @@ -5,7 +5,7 @@ $("#project_funder_id").change(function(){ reloadTemplateData(); - if($(this).val().length > 0){ + if($(this).select2().val().length > 0){ $("#other-funder-name").hide(); $("#project_funder_name").val(""); @@ -15,14 +15,14 @@ $("#institution-control-group").show(); $("#create-plan-button").show(); - $("#confirm-funder").text($(this).val()); + $("#confirm-funder").text($("#project_funder_id option:selected").text()); }); // ---------------------------------------------------------- $("#project_institution_id").change(function(){ reloadTemplateData(); - $("#confirm-institution").text($("#project_institution_id").select2('data').text); + $("#confirm-institution").text($("#project_institution_id option:selected").text()); }); // ---------------------------------------------------------- @@ -33,7 +33,11 @@ // ---------------------------------------------------------- $("#no-funder").click(function(e) { e.preventDefault(); - $("#project_funder_id").select2("val", ""); + // For some reason we need to access the select2 box's value again to get the + // UI to update correctly + $("#project_funder_id").select2().val(""); + $("#project_funder_id").select2().val(); + $("#institution-control-group").show(); $("#create-plan-button").show(); $("#other-funder-name").show(); @@ -47,7 +51,11 @@ // ---------------------------------------------------------- $("#no-institution").click(function() { - $("#project_institution_id").select2("val", ""); + // For some reason we need to access the select2 box's value again to get the + // UI to update correctly + $("#project_institution_id").select2().val(""); + $("#project_institution_id").select2().val(); + $("#confirm-institution").text(I18n.t("helpers.none")); });