Skip to content

List.js doesn't work in Elementor widget - WooCommerce products #784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gonzalesc opened this issue Apr 21, 2025 · 0 comments
Open

List.js doesn't work in Elementor widget - WooCommerce products #784

gonzalesc opened this issue Apr 21, 2025 · 0 comments

Comments

@gonzalesc
Copy link

gonzalesc commented Apr 21, 2025

Hi.

I have a shortcode that displays the WC products in a table using List.js. It works : example1 here

I then created an Elementor widget that uses the same shortcode to display the WC products table, and it works but the List.js shows and error:

Uncaught TypeError: Cannot read properties of undefined (reading 'childNodes')
here : example2 here

I have tried using Elementor hooks on the frontend, but it always shows the error.

jQuery( window ).on( 'elementor/frontend/init', () => {
    const addHandler = ( $element ) => {
        
        console.log('hello');
        console.log($element);

        console.log( $element.find( 'table tbody' ).html() );

        const wcProductTable = new List( 'wc-product-table', {
            valueNames: ['image', 'name', 'stock', 'stock_status', 'qty', 'price', 'rating', 'variations', 'cart', 'price_raw', 'rating_raw', 'sales_raw', 'creation_raw'],
            page: 11,
            pagination: true
        } );
    };
 
    elementorFrontend.hooks.addAction( 'frontend/element_ready/wc_product_table.default', addHandler );
 } );

and, just for testing, I used setTimeOut with 6 seconds (to wait for the whole page to load) and the error was the same.

setTimeout( () => {
    const wcProductTable = new List( 'wc-product-table', {
            valueNames: ['image', 'name', 'stock', 'stock_status', 'qty', 'price', 'rating', 'variations', 'cart', 'price_raw', 'rating_raw', 'sales_raw', 'creation_raw'],
            page: 11,
            pagination: true
        } );
}, 6000 );

Note: This script Js depends of List.js and Elementor Fronted : [ 'list-table', 'elementor-frontend' ]

Please, any advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant