eCommerce Ecwid

Ecwid onPageLoaded early firing

0
0 0

If you want any JavaScript or jQuery script code to run when a certain page in the product browser widget of Ecwid is open, you need to use the Ecwid JavaScript API, more exactly the OnPageLoaded event.

Your js code should be wrapped into the function, then the function needs to be added to the OnPageLoaded hadlers.

For example, to add a placeholder to the search input you need to use the following code:

if (typeof(Ecwid) == 'object') {
    // an Ecwid JS API call
    Ecwid.OnPageLoaded.add(
        // Regular JS Code
        function(page) { 
            if (jQuery('.ecwid-SearchPanel-field').length){  
                jQuery('.ecwid-SearchPanel-field').attr('placeholder', 'Enter your search term');
            }
        }
    );
}

References: jsFiddle, Ecwid forum.

Stanley
I am a self made webmaster, blogger, web technology enthusiast and founder of StanleyTips.com.
You may also like
Best PrestaShop Themes in 2016

Enjoy This Article?

Join My Mailing List...

Facebook

Twitter

THANK YOU