• Resolved pavel089

    (@pavel089)


    Hi everyone
    I am writing an extension for the WordPress media library, I need to add a button to the media library, by clicking on which a modal window will open from where the user can select a picture.

    See the screenshots
    screenshot 1
    screenshot 2
    At the moment, the event does not fire when the button is clicked when the library is open when editing the page with the Elementor plugin. JS file is included as follows:

    public function registerAssets()
    {
        //add_action('admin_enqueue_scripts', [$this, 'scripts']);
        add_action('wp_enqueue_scripts', [$this, 'scripts']);
    }
    
    public function scripts()
    {
        wp_register_script( 'cbi-index-js', SCRIPTS_URI . 'index.js', [ 'elementor-frontend' ], '1.0.0', true );
        wp_enqueue_script('cbi-index-js');
    }

    Everything works as it should in the admin area, but in Elementor the problem is probably in the namespace.
    JS file

    jQuery(window).on('elementor/frontend/init', function (){
        jQuery('#db-upload-btn').on('click', function (){
            console.log(222)
        })
    })
    console.log(333)
    

    As you can see, I also output console.log (333) to the console and when I reload the page, being in the Elementor panel, 333 is output to the console, which indicates that the file has connected, but why the handler does not work when I click on the button yet I can figure it out.

    Can someone help me with this?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Js event does not work in the Elementor plugin’ is closed to new replies.