In the back-office, when we create a page, we can add sections and rows in which we can create elements. These elements are for example text boxes, images, buttons, and other Visual Composer mappings manually declared in functions.php for example, using the function vc_map.

When we want to add one of these elements to a section/row, we click on its icon and another pop-in is shown. The latter contains fields required by the element (the text and the image for a button, etc.).

This question is about this pop-in. Is there any JavaScript event triggered after it's opened? Is it possible to listen for it?

I saw that an AJAX query is sent asking for admin-ajax.php and then edit-form.min.js.

I can look for PHP hooks and filters too, you know.


Solution: add an action on the tag vc_edit_form_fields_after_render.

    add_action( 'vc_edit_form_fields_after_render', function() {
        echo  '<script src="' . AN_URL . 'test.js"></script>';  // Or something other
    }, 9 );

In the functions.php or equivalent.

(Indeed, the tag vc_edit_form_fields_after_render is used by do_action( 'vc_edit_form_fields_after_render' ) which is located in js_composer\include\classes\editors\class-vc-edit-form-fields.php . So what you type in your add_action callable will be executed after, and only after, the user has opened the Edition pop-in presented in the OP message - this is what I was asking for).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.