0

I want to add the class ms-hideto the body of my master page depending on certain conditions.

I'm trying to do something like delegate controls where, based on a feature I add or remove this class from my body.

I'm doing a lot of DOM manipulation on my project sites and I want to hide the body until it's ready then fade it in.

0

One option, showing the power of CSS

add a STYLE tag to your document, preferably in the HEAD, but can be placed anywhere

<style id="hiddenHTML">
  :root body{
     visibility:hidden;
   }
</style>

This hides the body tag, but you can still do DOM manipulations

Once you are ready you disable the whole STYLE definition

document.getElementById('hiddenHTML').disabled=true;
  • Well I can already use ms-hide for styling so that's fine. My issue is that I need the styling to be determined based on some variable server site or on render. Essentially, I have /projects/home (I don't need to hide things there) but then I have /projects/proj-2016/1( to n) So I'm trying to find a way to have this class applied to the body depending on what collection I'm in or if a feature has been enabled (like delegate controls) etc. – Batman Apr 7 '17 at 18:42
  • Apply a UserCustomAction ScriptLink so it executes on every page and whack that class in with JS – Danny '365CSI' Engelman Apr 7 '17 at 18:44
  • I'll try that. Hopefully it's fast enough to apply the styling right away. I was assigning styling on $.ready but then it would stutter between displayed and hidden, then displayed again when my DOM manipulations where done. – Batman Apr 7 '17 at 18:57
  • That's why you do the reverse with the STYLE, hide always and show on /projects/home – Danny '365CSI' Engelman Apr 7 '17 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.