SKOOMA
SKOOMA

Reputation: 1

Custom Elementor Widget Styling Issues: Front-End Styles Not Reflected in Elementor Editor - Assistance Needed

I've developed a custom carousel widget for Elementor using the Slick slider. On the website's front-end, everything looks and works as expected; the styling of the carousel is exactly how I want it. However, I'm encountering an issue when it comes to viewing and editing this widget within the Elementor editor itself. The styles applied to the front-end do not reflect in the Elementor editor, which is not only confusing from a design consistency standpoint but also limits the user's ability to see their modifications in real-time as they insert content into the widget's input fields.

I'm aiming for a seamless design experience where the widget's appearance in the Elementor editor mirrors its front-end display, including the immediate reflection of content updates made by the user. This would significantly improve the user interface and editing experience for those working with my custom widget.

linked-carouselle.php:

 enqueue

widgets\carouselle-widget.php:

My class

My controls pt.1

My controls pt.2

Render function in my class

Upvotes: 0

Views: 227

Answers (1)

R Z
R Z

Reputation: 21

For those who experience issue with loading the slick styles and scripts in elementor editor. Simply enqueue your script with following action hooks

In plugin functions

function widgets_enqueue_scripts()
    {
        wp_register_script(
            'widgets_script',
            plugin_dir_url(__FILE__) . 'js/widgets.js',
            array('jquery'),
            '1.3',
            true
        );
        wp_enqueue_script('widgets_script');
    }

In enqueued js

jQuery(window).on('elementor/frontend/init', function () {
        elementorFrontend.hooks.addAction('frontend/element_ready/global', function ($scope) {
    
            jQuery('.__academics').each(function () {
                console.log('Found:', jQuery(this));
                if(!jQuery(this).hasClass('slick-initialized')){
                    jQuery(this).slick({
                        dots: true,
                        infinite: true,
                        speed: 400,
                        slidesToShow: 5,
                        arrows: true,
                        autoplay: true,
                        responsive: [{
                            breakpoint: 1024,
                            settings: {
                                slidesToShow: 4,
                                slidesToScroll: 1,
                                infinite: true,
                                dots: false
                            }
                        },
                        {
                            breakpoint: 992,
                            settings: {
                                slidesToShow: 3,
                                slidesToScroll: 1,
                            }
                        },
                        {
                            breakpoint: 480,
                            settings: {
                                slidesToShow: 1,
                                slidesToScroll: 1
                            }
                        }
        
                        ]
                    });
                }
            });
        });
    });

Upvotes: 0

Related Questions