skip to Main Content

I have a requirement where I need to create a custom widget to Elementor. I will have two text fields and a button on this widget and when I click on Button. I have to trigger an event.

But, I am not getting any button Id on the HTML page when I tried to create a button using this code.

          'submit_content',
          [
            //'label' => __( 'Submit Content', 'plugin-name' ),
            'type' => ElementorControls_Manager::BUTTON,
            'separator' => 'before',
            'button_type' => 'success',
            'text' => __( 'Submit Product', 'plugin-domain' ),
            'event' => 'namespace:editor:submit',
          ]
        );

Is there any way, I can create any id with this button? Or any way I can use this button on click event at javascript or PHP side?

2

Answers


  1. jQuery(window).on("elementor/frontend/init", function() {
        elementor.channels.editor.on('namespace:editor:submit', function() {
            console.log('Try this!');
        });
    });
    
    Login or Signup to reply.
  2. Also you can call it by javascript (without using jquery) like this :

     <script>
        if (elementorFrontend.isEditMode()) {            
         elementor.channels.editor.on('namespace:editor:submit', () => { 
             alert('Hello Elementor') ; 
         });
        }   
    </script>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search