Sha256: aff467793ea6bdde321ca44adeafd1ae3e773a8ce5e0071dba9b914f761d93bc
Contents?: true
Size: 618 Bytes
Versions: 33
Compression:
Stored size: 618 Bytes
Contents
import { Controller } from '@hotwired/stimulus' // Connects to data-controller="switcher" export default class extends Controller { originalText = null textEl = null connect () { this.textEl = this.element.querySelector('.text') this.originalText = this.textEl.textContent this.element.addEventListener('click', () => { this.cambiarTexto() }) this.cambiarTexto() } cambiarTexto () { if (this.element.getAttribute('aria-expanded') === 'true') { this.textEl.textContent = this.element.dataset.expandedText } else { this.textEl.textContent = this.originalText } } }
Version data entries
33 entries across 33 versions & 1 rubygems