Dialog CSS

Forums General discussion Dialog CSS

This topic contains 4 replies, has 2 voices, and was last updated by  Alexander Bautz 2 months, 3 weeks ago.

  • Author
    Posts
  • #23818

    Bob Hornak
    Participant

    Hi Alex,
    Is it possible apply custom JS or CSS based on whether or not a form is opened in Dialog mode?

    Thanks,
    Bob

  • #23820

    Alexander Bautz
    Keymaster

    I’m not sure you can use css directly, but js is no problem. Add this to your Custom JS to run code only in a dialog:

    if(GetUrlKeyValue("IsDlg") === "1"){
    	alert("Is in a dialog");
    }

    What is it you want to style differently?

    Alexander

  • #23941

    Bob Hornak
    Participant

    Hi Alex,
    Sorry for the delay, was pulled in a different direction for bit.. 🙂

    The reason is this…and maybe you have a better approach….

    When a “NewForm.aspx” is used in a full window scenario (ie New button on list view) I style the form with CSS to be center position and no left hand navigation. When the form is called in a popup scenario, it is then shifted right and you need to use the scroll bar, not ideal.

    If I remove CSS to hide left navigation, then it looks great in popup scenarios, but then not centered when in full screen scenario.

    Any thoughts?
    Thanks,
    Bob

  • #23945

    Bob Hornak
    Participant

    Alex,
    I was able to leverage this from the forums and it seems to meet my requirements! 🙂 If you think there is better approach, please let me know, otherwise Great job again!

    if(GetUrlKeyValue(“IsDlg”) !== “1”){
    cssBuffer.push(“#sideNavBox {DISPLAY: none}”)
    cssBuffer.push(“#sideNavBox {WIDTH: 0px!important;}”)
    cssBuffer.push(“#contentBox {MARGIN-LEFT: auto!important;}”)
    cssBuffer.push(“#contentBox {MARGIN-RIGHT: auto!important;}”)
    cssBuffer.push(“#contentBox {WIDTH: 500px!important;}”)
    $(“body”).append(“<style type=’text/css’>”+cssBuffer.join(“”)+”</style>”);
    }

    Thanks again
    -Bob

  • #23957

    Alexander Bautz
    Keymaster

    This looks good – I’m glad you figured it out.

    Alexander

You must be logged in to reply to this topic.