Last active
February 3, 2023 17:23
-
-
Save steveosoule/a2c2c16fcbfbf0cdc3c47bf2b70e5472 to your computer and use it in GitHub Desktop.
Miva - MMX Hero Slider Manipulations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add a new mmx-hero slide with custom slotted content | |
| const slider = document.getElementById('mmx-hero-slider__mmx_heroslider'); | |
| const firstSlide = slider.querySelector('[slot="hero_slide"]'); | |
| const newSlideHTML = /*html*/` | |
| <mmx-hero slot="hero_slide"> | |
| <div slot="content">Custom Banner</div> | |
| </mmx-hero> | |
| `; | |
| firstSlide.insertAdjacentHTML('afterend', newSlideHTML); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Replace second slide with a new mmx-hero slide and custom slotted content | |
| const slider = document.getElementById('mmx-hero-slider__mmx_heroslider'); | |
| const secondSlide = slider.querySelector('[slot="hero_slide"]:nth-child(2)'); | |
| const newSlideHTML = /*html*/` | |
| <mmx-hero slot="hero_slide"> | |
| <div slot="content">Custom Banner</div> | |
| </mmx-hero> | |
| `; | |
| secondSlide.outerHTML = newSlideHTML; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add any custom HTML as the second slide | |
| const slider = document.getElementById('mmx-hero-slider__mmx_heroslider'); | |
| const firstSlide = slider.querySelector('[slot="hero_slide"]'); | |
| const newSlideHTML = /*html*/`<div slot="hero_slide">Custom Banner</div>`; | |
| firstSlide.insertAdjacentHTML('afterend', newSlideHTML); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Replace the second slide with any custom HTML | |
| const slider = document.getElementById('mmx-hero-slider__mmx_heroslider'); | |
| const secondSlide = slider.querySelector('[slot="hero_slide"]:nth-child(2)'); | |
| const newSlideHTML = /*html*/` | |
| <div slot="hero_slide">Custom Banner</div> | |
| `; | |
| secondSlide.outerHTML = newSlideHTML; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment