Home › Forums › General Issues › 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
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.