Divi自定义模块开启fb_support后可视化编辑器报错问题
Let me walk you through how to troubleshoot this common issue with Divi custom modules when enabling frontend builder (fb_support) support. That lockedParent error happens because Divi's Visual Builder can't properly recognize your module's DOM structure or initialization, leading to broken internal state.
Here are the most likely fixes to try:
1. Verify Your Frontend Builder Template Structure
When you set $this->fb_support = true, Divi expects your module to render a properly structured container for the Visual Builder to hook into. If your FB-specific template (usually frontend.php or a conditional in get_template()) is missing critical attributes or wrapping elements, the builder can't track the module's parent/child relationships.
Make sure your template includes these mandatory parts:
<div <?php $this->module_class(); ?> <?php $this->print_module_attributes(); ?>> <?php $this->render_builder_content(); ?> </div>
print_module_attributes()outputs Divi's requireddata-moduleand other builder-specific attributes—don't skip this! Without it, the Visual Builder can't identify your module, which triggers thelockedParentundefined error.render_builder_content()ensures any nested modules or builder content is loaded correctly in the Visual Builder.
2. Check Module Initialization Logic
Double-check your module's constructor to ensure you're setting up FB support correctly, including enqueuing any necessary scripts for the builder environment:
public function __construct() { parent::__construct(); $this->fb_support = true; // Enqueue frontend scripts (for both frontend and builder) add_action('wp_enqueue_scripts', array($this, 'enqueue_frontend_scripts')); // Enqueue builder-specific scripts if needed add_action('divi_builder_frontend_scripts', array($this, 'enqueue_fb_scripts')); }
Avoid any logic that skips rendering the module container in the FB environment—even if your module is simple, it needs that wrapping div for the builder to function.
3. Rule Out Custom Script Conflicts
If your module includes custom JavaScript, it might be interfering with Divi's internal Visual Builder logic. For example:
- Accidentally modifying or overriding Divi's
et_pb_moduleobject properties - Loading scripts that run too early (before the builder has initialized modules)
Try temporarily disabling your module's custom JS. If the error goes away, debug your script to ensure it's compatible with the Visual Builder:
- Wrap builder-specific logic in a check for the Divi builder environment:
if (typeof et_pb_global !== 'undefined' && et_pb_global.is_frontend_builder) { // Your builder-compatible JS here } - Don't access internal Divi properties like
lockedParentdirectly—stick to the official Divi module API.
4. Check Divi Version Compatibility
You're using Divi 3.0.106, which is an older version. This version has known quirks with custom module FB support, and some API changes in newer versions might resolve your issue. If possible, update Divi to the latest stable release. If you can't update, review the v3.0.106 documentation to ensure you're following the exact FB support requirements for that version.
5. Debug the DOM and PHP Errors
- Browser Dev Tools: Inspect the page in the Visual Builder to see if your module's DOM element exists. If it's missing entirely, your PHP template is probably failing to render. If it exists but lacks
data-moduleattributes, you forgotprint_module_attributes(). - WP_DEBUG: Enable WordPress debug mode to check for PHP warnings/errors that might be breaking the template rendering. Even a small PHP notice can cause the Visual Builder to fail silently.
内容的提问来源于stack exchange,提问作者Toni Chaz

