Script failing to run in Hubspot 'Drop & drag' builder

amysotheran
Member


Hello everyone!

 

I'm hoping you can help me resolve a script related issue (I'm not super experienced with Javascript).

 

I have included a custom script in the header on my code to re-run the .gifs when a user hits the Bootstrap tabs (see code below):

 

// Function resets gif through id

function resetGif(id) {
var img = document.getElementById(id);
var imageUrl = img.src;
img.src="";
img.src=imageUrl;
}

function handleTabSelection(tabId) {
// Depending on the tab being clicked do different stuff
switch (tabId) {
case '#lA':
doSomethingElse()
break;
case '#lB':
resetGif('gif02')
break;
case '#lC':
resetGif('gif01')
break;
case '#lD':
doSomeAnimation()
break;
default:

}
}

function attachTabShownEventHandler() {
const tabSelector = '.nav-tabs li div[data-toggle="tab"';
const eventType = 'shown.bs.tab';
const tabIdAttribute = 'data-target';
$(tabSelector).on(eventType, function(event){
const id = event.target.getAttribute(tabIdAttribute);
handleTabSelection(id);
});
}

/// When the document is loaded then attach an event handler that listens to all the shown events on the tabs
$(document).ready(function(){
attachTabShownEventHandler();
});

 

For some unknown reason the script runs correctly when I setup the template file as 'HTML&HUBL' (with the Hubspot footer removed) but not when I place it within the 'Drag & drop' builder template. The script only ran in the 'HTML&HUBL' template once I removed the footer. So I suspect this could be causing some issue.

 

'HTML&HUBL' : https://preview.hs-sites.com/_hcms/preview/template/multi?domain=undefined&portalId=1951002&tc_devic...

 

'Drop & drag' : https://preview.hs-sites.com/_hcms/preview/template/multi?is_buffered_template_layout=true&portalId=...

 

Has anyone ran into these issues before? I appreciate any help.

 

Thanks,

Amy

0 Upvotes
1 Reply 1
sharonlicari
Community Manager

Hey @amysotheran 

 

I apologize for the delay in getting back to you. I am wondering if you were able to resolve this or if you still need assistance on this matter? 

 

Thank you

Sharon


¿Sabías que la Comunidad está disponible en Español?
¡Participa hoy en conversaciones en el idioma de tu preferencia,cambiando el idioma en tus configuraciones!

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


0 Upvotes