Support

Account

Home Forums General Issues Disable editing in repeater wysiwyg sub field

Unread

Disable editing in repeater wysiwyg sub field

  • I am trying to sisable editing in repeater wysiwyg sub field. I will be disabling the ability to edit based on user role, but for now I am just trying to get the jquery to work do disable editing of the field.

    There are 2 ways I have thought to approach this thus far.

    1. Set the content editable value of the iframes body tag to false

    $(".post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input iframe body").setAttribute('contenteditable',false);

    2. Get the content of the iframes body, remove the iframe, add the iframes content back in rg

    var wysiwygContent = $('.post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input iframe html body').contents();
    		$('.post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input iframe').remove()
    		$('.post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input').append(wysiwygContent);

    I am running both functions from the admin_print_footer_scripts hook

    Thus far I have had no joy with either. Oddly the second method does sporadically remove the iframe, thought it doesn’t do so every page load and it doesn’t add the content back into the td.acf-input div

    Here is the full code

    //Backend jquery
    add_action('admin_print_footer_scripts', 'ttm_admin_jquery');
    function ttm_admin_jquery(){
    ?>
    <script>
    jQuery(function($) {
    	$(document).ready(function(){
    		$('.taxonomy-suppliers #tag-slug').parent().remove();
    		$('.taxonomy-suppliers #tag-description').parent().remove();
    		$('.taxonomy-suppliers #description').closest( 'tr' ).remove();
    		
    		//Stop installation posts info fields from being editable
    		var wysiwygContent = $('.post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input iframe html body').contents();
    		//$('.post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input iframe').attr("src", " ");
    		$('.post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input iframe').remove()
    		$('.post-type-installations table.acf-table tr.field_key-field_539b0c5f32390 td.acf-input').append(wysiwygContent);
    		//.contents().find('body#tinymce').contentEditable = false
    			
    	});
    });
    </script>
    <?php
    }

    Any help appreciated

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.