From c7b47315b5687f8efb9b7e2d1634bb108fb36c70 Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Mon, 28 Sep 2020 16:38:18 +0200 Subject: [PATCH] M #~: Fix images creation dialog (#254) --- .../images-tab/form-panels/create-common.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/sunstone/public/app/tabs/images-tab/form-panels/create-common.js b/src/sunstone/public/app/tabs/images-tab/form-panels/create-common.js index 097e5db2ec5..fa723458de8 100644 --- a/src/sunstone/public/app/tabs/images-tab/form-panels/create-common.js +++ b/src/sunstone/public/app/tabs/images-tab/form-panels/create-common.js @@ -209,16 +209,19 @@ define(function(require) { }); // Custom Adapter Type - var custom_attrs = ["vcenter_adapter_type", - "vcenter_disk_type", - "img_dev_prefix", - "img_driver"]; - - for (var i in custom_attrs){ - var field = custom_attrs[i]; + var custom_attrs = [ + "vcenter_adapter_type", + "vcenter_disk_type", + "img_dev_prefix", + "img_driver" + ]; + + $(custom_attrs).each(function(_, field) { $('input[name="custom_'+field+'"]',context).parent().hide(); - $('select#'+field,context).change(function(){ + + $('select#'+field, context).on("change", function() { var field = $(this).attr('name'); + if ($(this).val() == "custom"){ $('input[name="custom_'+field+'"]',context).parent().show(); $('input[name="custom_'+field+'"]',context).attr('required', ''); @@ -227,7 +230,7 @@ define(function(require) { $('input[name="custom_'+field+'"]',context).removeAttr('required'); } }); - } + }); $('#img_path,#img_size,#file-uploader', context).closest('.row').hide();