Category : Ecwid

eCommerce Ecwid

Ecwid onPageLoaded early firing

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.

Read More

Enjoy This Article?

Join My Mailing List...

Facebook

Twitter

THANK YOU