Recent searches


No recent searches

New Edit of Help Center Template Not Working

Answered


Posted May 17, 2023

Hi Everybody!

I have a Help Center theme that was edited some time ago to hide one specific form from all users, except the members of a specified organization and has been working fine ever since.

But things evolve and we now need to hide two forms. One from all but one organization and one from all but two organizations. However, the new code I have in place isn't working correctly and I'm not really sure why. But I'm a real novice with HTML so that's not really all that surprising.

When the new code is added to a test template and the preview is run. It does not change the visible forms and appears to still be using the code that is currently in the live theme.

I have also swapped the live theme after hours to confirm that it was not a buggy preview feature. But the behavior was consistent.

The new form is not visible despite the account used for testing being an administrator and in the correct organization. While the old form was still visible despite the test account not being in the required organization.

Below is the code that the live site is using.

document.addEventListener('DOMContentLoaded', function() {
  // Key map
  var ENTER = 13;
  var ESCAPE = 27;
  var SPACE = 32;
  var UP = 38;
  var DOWN = 40;
  var TAB = 9;
  
  var i = 0;
     var checkExist = setInterval(function() {
     i++;
     if ($("a.nesty-input").length){
     clearInterval(checkExist);
     $("a.nesty-input").each(function() {
     $(this).bind( "click", function() {
     for (var c in HelpCenter.user.organizations) {
     if (HelpCenter.user.organizations[c].name === "Managers"){
     $("#360003482932").show();
     }
    
   else{$("#360003482932").hide()}  

And here is the new code that replaced it.

document.addEventListener('DOMContentLoaded', function() {
  // Key map
  var ENTER = 13;
  var ESCAPE = 27;
  var SPACE = 32;
  var UP = 38;
  var DOWN = 40;
  var TAB = 9;
  
  var i = 0;
     var checkExist = setInterval(function() {
     i++;
     if ($("a.nesty-input").length){
     clearInterval(checkExist);
     $("a.nesty-input").each(function() {
     $(this).bind( "click", function() {
     for (var c in HelpCenter.user.organizations) {
     if (HelpCenter.user.organizations[c].name === "Managers" || HelpCenter.user.organizations[c].name === "HR"){
     $("#360003482932").show();
     }
    
   else{$("#360003482932").hide()}  
   
     if (HelpCenter.user.organizations[c].name === "HR"){
     $("#4992348743700").show();
     }
    
   else{$("#4992348743700").hide()}  

As you can see the changes are not very significant. Does anyone have any idea why the HC would still be producing the same behavior now as before the change?


0

5

5 comments

image avatar

Jean-Francois Weston

Zendesk Customer Care

Hi Damon. 
I see you have created a conversation for our technical support team, with the same question.
I will reach out in this conversation then, if this suit.
Thank you

0


Hi Jean,

This thread will be just fine to discuss the issue.

As far as I can tell the code itself is correct, as part of it is already working as expected. However, another part of it, using exactly the same structure, doesn't seem to be applying at all. Which makes me think that the new form's ID needs to be added to style.css or one of the HBS template files in the theme.

Does the new form ID have to be added to any other resources before the code in Script.js can recognize it?

0


image avatar

Jean-Francois Weston

Zendesk Customer Care

Hey Damon,
I have sent you an answer in the ticket opened, already.
Bests

-1


Can we get the answer in this forum so people researching the same issue can have the answer as well?

0


image avatar

Jakub

Zendesk Customer Care

Hello Taeha,
 
as the code provided by Damon is specific to his use case it is essential that it is reviewed on per case basis, as general answer would be misleading for somebody trying to achieve a similiar goal, each costum code solution should be tailered 

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post