Comments 3David started the conversationOctober 27, 2024 at 1:36pmHi.Not sure if this is included in support, but...I'm trying to communicate between two popup sliders. When a button is clicked in one, the other closes:document.addEventListener('DOMContentLoaded', function() { // Handle button click inside the 'christmas-sale' slider const christmasButton = document.getElementById('view-christmas-sale') christmasButton.addEventListener('click', () => { const snowmanGlobeSlider = document.querySelector('[data-ls-slug=snowball-lightbulb]').layerSlider() snowmanGlobeSlider.api('closePopup') // Close popup in snowman-globe slider }) // Handle button click inside the 'snowman-globe' slider const snowmanButton = document.getElementById('view-christmas-ornaments') snowmanButton.addEventListener('click', () => { ⌬ tabnine {} const christmasSaleSlider = document.querySelector('[data-ls-slug=christmas-bottom-bar]').layerSlider() christmasSaleSlider.api('closePopup') // Close popup in christmas-sale slider }) }) I get the following error:Uncaught TypeError: document.querySelector(...).layerSlider is not a function at HTMLSpanElement.<anonymous> (layerslider.js?ver=1730035793:8:96) 138George repliedOctober 28, 2024 at 3:43pmHello David, I've modified the end of your code:snowmanButton.addEventListener('click', () => { ⌬ tabnine {} const christmasSaleSlider = document.querySelector('[data-ls-slug=christmas-bottom-bar]') christmasSaleSlider.layerSlider('closePopup') // Close popup in christmas-sale slider }) I think, that should work.Best Regards,George | Kreatura Dev Team 3David repliedOctober 29, 2024 at 11:44amUnfortunately, this didn't work either. However, I came up up with an acceptable solution. I'll leave it here in case anybody else has the same problem.In the Project -> Event Callbacks list, I modified the "sliderDidLoad" function as such:function( event, slider ) { window.christmasSaleSlider = slider}Then in my javascript: window.cmcGoToOrnaments = () => { window.christmasSaleSlider.api('closePopup') // Close popup in christmas-sale slider setTimeout(() => { window.location.href = "<forwarding-url>" }, 500) }A lot of global variables, but other than that, it seems to work well.Thanks for your help!1 Like 138George repliedOctober 29, 2024 at 6:31pmNice solution! Thank you for the feedback!Best Regards,George | Kreatura Dev Team Sign in to reply ...
Hi.
Not sure if this is included in support, but...
I'm trying to communicate between two popup sliders. When a button is clicked in one, the other closes:
document.addEventListener('DOMContentLoaded', function() {
// Handle button click inside the 'christmas-sale' slider
const christmasButton = document.getElementById('view-christmas-sale')
christmasButton.addEventListener('click', () => {
const snowmanGlobeSlider = document.querySelector('[data-ls-slug=snowball-lightbulb]').layerSlider()
snowmanGlobeSlider.api('closePopup') // Close popup in snowman-globe slider
})
// Handle button click inside the 'snowman-globe' slider
const snowmanButton = document.getElementById('view-christmas-ornaments')
snowmanButton.addEventListener('click', () => { ⌬ tabnine {}
const christmasSaleSlider = document.querySelector('[data-ls-slug=christmas-bottom-bar]').layerSlider()
christmasSaleSlider.api('closePopup') // Close popup in christmas-sale slider
})
})
I get the following error:
Uncaught TypeError: document.querySelector(...).layerSlider is not a function
at HTMLSpanElement.<anonymous> (layerslider.js?ver=1730035793:8:96)
Hello David,
I've modified the end of your code:
snowmanButton.addEventListener('click', () => { ⌬ tabnine {}
const christmasSaleSlider = document.querySelector('[data-ls-slug=christmas-bottom-bar]')
christmasSaleSlider.layerSlider('closePopup') // Close popup in christmas-sale slider
})
I think, that should work.
Best Regards,
George | Kreatura Dev Team
Unfortunately, this didn't work either. However, I came up up with an acceptable solution. I'll leave it here in case anybody else has the same problem.
In the Project -> Event Callbacks list, I modified the "sliderDidLoad" function as such:
function( event, slider ) {
window.christmasSaleSlider = slider
}
Then in my javascript:
window.cmcGoToOrnaments = () => {
window.christmasSaleSlider.api('closePopup') // Close popup in christmas-sale slider
setTimeout(() => {
window.location.href = "<forwarding-url>"
}, 500)
}
A lot of global variables, but other than that, it seems to work well.
Thanks for your help!
Nice solution! Thank you for the feedback!
Best Regards,
George | Kreatura Dev Team