• Michael Garcia

    (@progressionstudios)


    I’m adding some additional widgets to the page builder and want to include custom javascript. I found the API for enqueueing javascript however ran into issues: https://github.com/pojome/elementor/blob/develop/docs/content/hooks/php-hooks.md#frontend-actions

    The code works great when I view the page on the front-end, however when I open up the Elementor editor the javascript doesn’t load. Let me know if this is a bug OR if I should be enqueuing using a different function.

    Even better, is there code to enqueue JS per widget/element? I tried using wp_enqueue_script within the protected function render() {} which worked on the front-end but again didn’t work when viewing using the elementor editor.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Michael Garcia

    (@progressionstudios)

    Additional Information on issue:

    I’m having trouble enqueuing scripts and styles. I setup a simple CSS file that forces the background red for testing. This works when viewing the frontend; however when I view the backend the style-sheet does not get loaded. What is the proper way to enqueue script/styles?

    Screen-shot Front-end showing style-sheet applied: http://i.imgur.com/QaN9UGO.png
    Screen-shot showing missing style-sheet when editor open (No Red Background): http://i.imgur.com/gYk2xQY.png

    Code being used:

    add_action( 'elementor/frontend/before_enqueue_scripts', function() {
    	wp_enqueue_style( 'example-frontend-styles' );
    } );

    Second Question: Is there code to enqueue CSS/JS per widget/element? I tried using wp_enqueue_style within the protected function render() {} which worked on the front-end but again didn’t work when viewing using the elementor editor. Same issue as above.

    Plugin Author ArielK

    (@arielk-1)

    Thanks for your comment, we’ll consider it for the next versions.

    Note: This is the kind of issue that you can write in our project at GitHub.
    https://github.com/pojome/elementor/issues

    • This reply was modified 9 years, 1 month ago by ArielK.
    Plugin Author Yakir Sitbon

    (@kingyes)

    Please see this example how to use custom JS code in widgets: https://github.com/pojome/elementor-hello-world/commit/9e11c31c67440fa3be7e3a35df196d7b049a74cd

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

The topic ‘Possible bug with elementor/frontend/before_enqueue_scripts’ is closed to new replies.