From 922b3c078411138c139d4a70aa6a0d81d9ad0c23 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 17 Jun 2013 22:12:53 +0000 Subject: [PATCH] Get edit dialog country selection 'Custom' toggles working again --- addressbook/js/app.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 6f2c625645..874265624e 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -153,8 +153,8 @@ function add_whole_list(list) function show_custom_country(selectbox) { if(!selectbox) return; - custom_field_name = selectbox.name.replace("countrycode", "countryname"); - custom_field = document.getElementById(custom_field_name); + var custom_field_name = selectbox.name.replace("countrycode", "countryname"); + var custom_field = document.getElementById(custom_field_name); if(custom_field && selectbox.value == "-custom-") { custom_field.style.display = "inline"; } @@ -163,6 +163,9 @@ function show_custom_country(selectbox) if((selectbox.value == "" || selectbox.value == null) && custom_field.value != "") { selectbox.value = "-custom-"; + // Chosen needs this to update + $j(selectbox).trigger("liszt:updated"); + custom_field.style.display = "inline"; } else @@ -183,3 +186,12 @@ function add_new_list() },'_self'); } } + +/** + * et2 specific initialization - can be moved to init() when addressbook gets converted to et2 + */ +$j('.et2_container').on('load',function() { + + $j('select[id*="adr_one_countrycode"]').each(function() {show_custom_country(this);}); + $j('select[id*="adr_two_countrycode"]').each(function() {show_custom_country(this);}); +});