Issue in Object.changePrimaryColor in layout.js

Post Reply
Posts: 479
Joined: 05 Mar 2010, 13:17

01 Dec 2022, 16:04


as soon I switch the "Layout Color" from the config.xhtml I got an JS error:

"layout.js.jsf?ln=rain-layout:546 Uncaught TypeError: Cannot read properties of undefined (reading 'indexOf')
at Object.changePrimaryColor (layout.js.jsf?ln=rain-layout:546:27)"


If I refresh the page, the layout has been changed correctly..
Any idea?
Primefaces 8.0, WildFly 21

Posts: 5237
Joined: 29 Jun 2013, 12:38

05 Dec 2022, 12:27

Do you have a link element that contains layout styles? Could you please check it in DOM? For now, you can add a null check to href variable. I'll add it too.

Code: Select all

changePrimaryColor: function(newColor, darkMode) {
        newLayout = this.getColor(newColor, darkMode);
        var linkElement = $('link[href*="layout-"]');
        var href = linkElement.attr('href');

        if (href) {
            var startIndexOf = href.indexOf('layout-') + 7;
            var endIndexOf = href.indexOf('.css');
            var currentColor = href.substring(startIndexOf, endIndexOf);
            this.replaceLink(linkElement, href.replace(currentColor, newLayout));

Post Reply

Return to “Rain - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest