• Hi,

    I built a simple front-end editor using Advanced Custom Fields textarea and applying some quicktags button to this element, see below

    add_action( 'wp_footer', 'prd_qktg_js', 100 );
    
    function prd_qktg_js()
    {
    
    ?>
    <script type="text/javascript">/* <![CDATA[ */
    
    // I just expect this to put some content as I click
        function callback_getit() {
        var my_content = "Luke, I'm your content";
        QTags.insertContent(my_content);
        }
    
        QTags.addButton( 'get_it', 'get it', callback_getit);
    
        var id = "acf-field_59a565c4fc77f"; // this is your metabox's textarea id
    
        settings = {
            id : id,
            buttons: 'strong,em,link,get_it' 
        }
    
        quicktags(settings);
    
    /* ]]> */</script>
    
    <?php   
    } 
    ?>

    The default ‘b’, ‘i’ and ‘link’ buttons work just good.
    The customized button ‘get it’ has callback_getit function as argument, but its behaving weirdly: when clicked it just does nothing UNTIL I try first using the default ‘link’ button, which open up its own wordpress modal. After closing the Insert link modal, my button works just fine.

    I think I missed some important JS but I still can’t figure out.
    Thank you in advance for any help.

    • This topic was modified 7 years, 2 months ago by PatrizioRD.
  • The topic ‘Quicktags on a front-end textarea, customized buttons show some JS issue’ is closed to new replies.