Skip Navigation

[Resolved] Custom js not working

This support ticket is created 7 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Konstantinos Galanakis 7 years, 6 months ago.

Assisted by: Konstantinos Galanakis.

Author
Posts
#444529

I am trying to: move my website as part of new multisite. Everything seems to be working, except my custom js (that is working fine in old website, stopped working in new place only. Seems like no other custom js are working too.

I visited this URL: hidden link

I expected to see: category list in pop - up sidebar. On click it opens, it is supposed to close back on click. but

Instead, I got: instead it is put then to the bottom of that layout. On old version of website (single site) ir worked well.

No plugins except Toolset, domain mapping and network user / plugins manager are on.

#444836

Hello. Thank you for contacting the Toolset Support.

I reviewed your custom js code and I found some issues with it, regarding the toggleClass function. You use two string replace method, one with regular expression trying to eliminate the tab character, the new line character and the return character but you are actually doing it wrong. On the other replace method, you are trying to remove the added “clicked” class, but you are adding another space character at the end of your “search” phrase, which makes the class not to be removed.

Please use the suggested code below and let me know if it fixes your issues.
*** Please keep in mind to backup your current code in case my suggestion doesn’t work. ***

function toggleClass(elem, className) {
	var newClass = ' ' + elem.className.replace( /\[trn]/g, " " ) + ' ';
    if (hasClass(elem, className)) {
        while (newClass.indexOf(" " + className + " ") >= 0 ) {
            newClass = newClass.replace( " " + className, " " );
        }
        elem.className = newClass.replace(/^s+|s+$/g, '');
    } else {
        elem.className += ' ' + className;
    }
}

If you have any further issues or questions, please let me know.

Regards

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.