• Resolved jqdieneudenker

    (@jqdieneudenker)


    When loading a form dynamically to a page, e.g. by ajax call, the initial conditional logic is not triggered. This is because the plugin only does the initial check on the “elementor/frontend/init” event.
    Instead an elementor elements handler class must be used, which then will automatically get attached and triggered on all form widgets once they get loaded.

    window.addEventListener(‘elementor/frontend/init’, () => {
    elementorFrontend.elementsHandler.attachHandler( ‘form’, YourConditionalLogicFrontendHandlerClass, ‘default’ );
    });


    YourConditionalLogicFrontendHandlerClass must extend elementorModules.frontend.handlers.Base

    Thanks and best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support himanshusharma20

    (@himanshusharma20)

    Hi @jqdieneudenker,

    Thank you for the information, but the current version does not support this. Our plugin’s JS file is maintained using functional standards, whereas this approach requires a class-based structure for the plugin JS file.

    Thank you.

    Thread Starter jqdieneudenker

    (@jqdieneudenker)

    Hi @himanshusharma20,
    Thanks for your quick response.
    Instead of moving towards a class-based structure you could also just replace the “elementor/frontend/init” event with the “frontend/element_ready” event: https://developers.elementor.com/docs/hooks/js/#frontend-element-ready-global

    So you could do:
    window.addEventListener(‘elementor/frontend/init’, function() {
    elementorFrontend.hooks.addAction( ‘frontend/element_ready/form.default’, function( $form ) {
    // YOUR CODE HERE:
    var formId = form.find(“.cfef_logic_data_js”).attr(“data-form-id”);
    form.attr(“data-form-id”, “form-” + formId);
    addHiddenClass(form, formId);
    logicLoad(form, formId);
    } );
    } );

    Thank you

    Plugin Support himanshusharma20

    (@himanshusharma20)

    Hi @jqdieneudenker,

    Thank you for the response and code snippets. If this code works for you, we will definitely check these code snippets inside our plugin, and if it works, we will add this in our upcoming updates.

    Thank you.

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

The topic ‘Initial conditional logic not working when forms are loaded dynamically’ is closed to new replies.