Sha256: 34868d346e6130cbb94e76e1123b62aa63ad277f83d81346a7c6f78a56d02f1a
Contents?: true
Size: 874 Bytes
Versions: 11
Compression:
Stored size: 874 Bytes
Contents
(() => { const application = Stimulus.Application.start() application.register("page-collapse", class extends Stimulus.Controller { static get targets() { return [ "list", "collapseLink", "expandLink" ] } expand() { this.toggleLinks(true) // Fetch children HTML fetch(this.element.dataset.url) .then(response => response.text()) .then(function(html) { // Render the list this.listTarget.innerHTML = html }.bind(this)) } collapse() { this.toggleLinks(false) // Clear the list this.listTarget.innerHTML = "" } // Toggle plus/minus links toggleLinks(expanded) { this.expandLinkTarget.style.display = expanded ? "none" : "inline-block" this.collapseLinkTarget.style.display = expanded ? "inline-block" : "none" } }) })()
Version data entries
11 entries across 11 versions & 1 rubygems