• Since I’ve updated to Gutenberg, I’m not able to get any of the AJAX functionality to work on the edit pages for my custom post types. For example, I’m using WooCommerce, and when I go to an “edit product” page, I can’t do things like expand/collapse meta boxes, drag to rearrange the meta boxes, or edit the slug. Is this a known issue? Is there a workaround? Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Can you open the Developer tools in your browser and view the Console while you try it? It should give some javascript error that is causing the scripts to fail.

    Thread Starter StevenJRossi

    (@stevenjrossi)

    Sure, thanks.

    I’m seeing this:

    Uncaught TypeError: Cannot read property 'length' of undefined
        at HTMLDocument.<anonymous> (post.php?post=12733&action=edit:278)
        at i (jquery.js?ver=1.12.4:2)
        at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
        at Function.ready (jquery.js?ver=1.12.4:2)
        at HTMLDocument.K (jquery.js?ver=1.12.4:2)

    That line, 278, looks like it’s got this:

    jQuery("#excerpt_counter").val(jQuery("#meta-textarea").val().length);

    Well, that line isn’t checking that jQuery returned anything before using its val function and then the val’s length.
    Since this is a CPT, can I assume it’s the Classic Editor (and since you mentioned metaboxes)? And is this excerpt_counter or meta-textarea something that WooCommerce is doing, or another plugin, or is it an editor thing?
    Depending on how you answer that, is where to go next for possible solutions. If it’s a plugin thing, you need to ask at the plugin’s support forum. Otherwise, I suppose using the Developer tools to see where those particular fields are used could help.

    Thread Starter StevenJRossi

    (@stevenjrossi)

    Yeah, the Classic Editor, and I’m not able to do anything ajax-y on the page, including expand/collapse the metaboxes but also including editing the slug inline or dragging metaboxes around. I suppose it may be an issue with WooCommerce, so I can take a look at their support forum — thanks for that suggestion. It seemed more likely to me to be a WP issue, but I’m not sure either way.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘AJAX in Custom Post Types Not Working in 5.0’ is closed to new replies.