Support

Account

Home Forums Gutenberg Update block preview on post title/fields change Reply To: Update block preview on post title/fields change

  • I thought it through a bit and came up with the code below. It works for my block, only on the back-end because we’re just using PHP on the front-end.

    if (is_admin()) { ?>
     <script>
      document.querySelector('.editor-post-title__input').addEventListener('input', (e) => {
       var title = e.target.value;
       document.querySelector('.SELECTOR-OF-ELEMENT-YOU-WANT-TO-CHANGE').innerHTML = title;
      });
     </script>
    <?php }