Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Disable jQuery in Admin View modes: 
User avatar
Member
Member
james.bills-columbiasouthern - 7/12/2011 3:30:03 PM
   
Disable jQuery in Admin
I created a page which hides div's using jQuery. I created three different webparts that are contained within these hidden div's. This obviously hides my webparts when trying to add content. Is there a quick and easy way of disabling the call to the jQuery script when I need to make updates. As for now, I would need to remove link to the script in the header every time I need to make a change. Thanks for any and all help.

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 7/13/2011 12:06:28 AM
   
RE:Disable jQuery in Admin
Hello,

You could try to obtain the ViewMode enum value from the cookie in your custom script and decide whether you show or hide your div elements.

Best regards
Ondrej Vasil

User avatar
Member
Member
james.bills-columbiasouthern - 7/13/2011 9:30:51 AM
   
RE:Disable jQuery in Admin
Thanks. Is this something I can do within the CMS?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 7/16/2011 5:35:47 AM
   
RE:Disable jQuery in Admin
Hello,

You can use a modification of the code below to execute your code according to the view mode of the site:

using CMS.CMSHelper;
...
ViewModeEnum currentMode = CMSContext.ViewMode;

switch (currentMode)
{
case ViewModeEnum.Edit:
/*You are in the edit mode*/
break;
case ViewModeEnum.LiveSite:
/*You are in the live site mode*/
break;
}

This can't be used directly in the CMS, however you can simply place the code in a custom transformation function or into a custom macro.

Best regards,
Boris Pocatko