Support » Developing with WordPress » Save text in a gutenberg block that was programmatically generated?

  • I’m having problems saving text in a field that’s in a block. I have a function that generates text in a field when you click on a button in the editor. The part where I’m having problems is saving the text to the post. The text disappears when you edit the post.

    I’ve tried using .val('hello world) and .attr('value', 'hello world');, both won’t save text that was generated.

    Here’s my code that’s in my theme’s functions.php:

    function shapeSpace_print_scripts() { 
    	?>
    	<script>
    		jQuery(document).ready(function ($) {
    			$(document).on( "click", '#yt_run .acf-button-group', function() {
    				$(".acf-field-60c3cc7056cc8 .acf-input input").attr('value', 'click_show_');
    			});
    		});
    	</script>
    	<?php
    }
    add_action('wp_print_scripts', 'shapeSpace_print_scripts');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.