From 6ec4f605f43b4e795d5d2b3a1ea746346cb33336 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Tue, 1 Dec 2015 17:22:09 -0800 Subject: [PATCH] Handle selecting 'no model' without JS errors. --- app/views/backend/hardware/edit.blade.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/backend/hardware/edit.blade.php b/app/views/backend/hardware/edit.blade.php index 167e927601..cbe5fac55e 100755 --- a/app/views/backend/hardware/edit.blade.php +++ b/app/views/backend/hardware/edit.blade.php @@ -361,11 +361,15 @@ $(function() { $('#model_select_id').on("change",function () { // console.warn("Model Id has changed!"); var modelid=$('#model_select_id').val(); - console.warn("Model ID is: "+modelid); - $.get("/hardware/models/"+modelid+"/custom_fields",{_token: "{{ csrf_token() }}"},function (data) { - // console.warn("Ajax call came back okay! Data is: "+data); - $('#custom_fields_content').html(data); - }) + if(modelid=='') { + $('#custom_fields_content').html(""); + } else { + // console.warn("Model ID is: "+modelid); + $.get("/hardware/models/"+modelid+"/custom_fields",{_token: "{{ csrf_token() }}"},function (data) { + // console.warn("Ajax call came back okay! Data is: "+data); + $('#custom_fields_content').html(data); + }); + } }); });