Search code examples
typo3tx-mask

TYPO3: Can i use a Mask field into javascript code


Can I use a TYPO3 Mask checkbox field into my javascript code, in fact I have a slider item and I want to add a checkbox for autoplay (on/off) in the backend of TYPO3, then the editor can use it.

          swipe: true,
          swipeToSlide: true,
          adaptiveHeight: true,
          touchThreshold: 10,
            autoplay: true,   <-----------
          autoplaySpeed: 3000,
        });

the mask screenshot


Solution

  • In order to pass content element data to JavaScript, I suggest the data-pattern:

    Fluid:

    <... data-slider-autoplay="{data.tx_mask_autoplay}">
    

    JavaScript:

    document.querySelector['[data-slider-autoplay]'].dataset.sliderAutoplay