The SharePoint 2010 standard model dialogs seamlessly blend transparent printing with the background content

When using Sharepoint 2010, each list item you edit will open in a new modal dialog box by default.

This dialog box appears as a new div with the class of ms-dlgContent. It also creates a div with the class of ms-dlgOverlay which acts as a grey overlay dimming the background. However, it does not alter the existing div that contains the background content, located within a div identified by the id of s4-workspace.

One issue that arises is when attempting to print the page while a dialog box is open. Since backgrounds do not print, the background of the dialog box and the ms-dlgOverlay div are ignored. This results in the fields of the dialog overlapping with the page content behind it, creating a messy appearance.

To address this, I have created a CSS stylesheet for printing purposes that hides the background content when a dialog is present. Although I can set the style of a div to display:none in the CSS sheet, I am unable to add a class to the s4-workspace element only if a dialog box is present. (I want the s4-workspace element to be visible when there is no dialog box open.)

I attempted to add the following script to my master page, but it did not work. I suspect this is because the dialog window does not exist during the initial page load, and I am unsure how to trigger my JavaScript code when a dialog opens or closes:

<script type="text/javascript">
    jQuery(function() {
        jQuery("#s4-workspace").removeClass("backgroundOfDialog");
        
        //this should run if the ms-dlgContent class is found and do nothing otherwise
        jQuery(".ms-dlgContent").parent().children("#s4-workspace").addClass("backgroundOfDialog");
    });
</script>

Answer №1

After much trial and error, I believe I have come up with a solution... albeit not the most efficient one. My current approach involves constantly checking the page every 5 seconds to determine if the dialog's div exists:

<script type="text/javascript">
    jQuery(function() {
        setInterval(checkForDialog, 5000);
    });

    function checkForDialog()
    {
        var dialogDiv = jQuery(".ms-dlgContent");
        if(dialogDiv.length)
        {
            jQuery("#s4-workspace").addClass("backgroundOfDialog");
        }
        else
        {
            jQuery("#s4-workspace").removeClass("backgroundOfDialog");
        }

    }
</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking for a checkbox change event that can detect and respond to changes in the checked state made programmatically

(jQuery 1.4.4) I am facing an issue with a checkbox where the .change() listener works well when the user manually clicks on the checkbox. However, I also require it to trigger when I programmatically change the status of the checkbox in jQuery using .at ...

"Using Rails remote link to create a standalone 'button' element, not embedded in a line of text or a

In my current project, I am attempting to create an ajax "button" that mimics the functionality of a typical link_to "content", some_path, remote:true. The goal is to have this button swap out images to indicate different statuses when clicked (e.g. on/off ...

Solution to ensure fixed header with correct z-index placement

Everything is functioning correctly, except for the issue that arises when scrolling down to view thumbnails. The left bar covers the thumbnail section, making it impossible to select items. I suspect that the z-index of a div is causing this problem. I ha ...

Buttons are not aligned with the rest of the row's height

I'm currently working on designing an upload layout that consists of a container with a row inside. Within the row, there are two buttons (each containing input elements) and one h3. For some reason, I am having difficulty getting them to align at the ...

Navigating horizontally with buttons in VueJS

I am searching for a way to implement horizontal scrolling using buttons in VueJS. The idea is to have a container with multiple divs arranged horizontally, and I wish to navigate through them using the buttons. If you want to see a similar solution using ...

What is the best way to target only the immediate children of a div when using tailwindcss?

Here is the HTML code snippet I am working with: <div class="section"> <div class="header">header</div> <div class="content"> <div>sub contents 1</div> <di ...

What is the best way to transfer the content from a tinyMCE textarea editor to an inner controller using Symfony3 and Ajax

I have two small rich text editors identified as #homepage and #thankyoupage. My goal is to submit the content of these TinyMCE text areas to a Symfony controller. Below is my front-end implementation: https://i.stack.imgur.com/TE1Ys.jpg Currently, I am ...

Tips for creating a fading effect when hovering over a div element

Hello, I am currently working on a project where I have a span that displays over an image on hover. I would like to add a bit of javascript or css transitions to make this div fade in to about 0.8 opacity when hovered over, and then fade back to 0 opacity ...

Switching "this" keyword from jQuery to TypeScript

A piece of code is functioning properly for me. Now, I aim to incorporate this code into a TypeScript application. While I prefer to continue using jQuery, I am unsure how to adjust the use of this to meet TypeScript requirements. if ($(this).width() < ...

Jquery Ajax Polling keeps scrolling to the top with each request

Currently, I am using the following function to display the active game list. However, I encounter an issue where if a player is scrolling through the list and triggers an ajax call, the page jumps to the top of the div which gets replaced by the response ...

jQuery not displaying Div elements as expected

After experimenting with the Coverflow technique and adapting it to work with a div, I have encountered a slight issue. Below is the HTML code I am using: <html> <head> <meta http-equiv="Content-type" content="text/html; ...

Utilizing Cookies within an HTML Page

My current code is functioning perfectly, accurately calculating the yearly income based on the input "textmoney." I have a link to a more advanced calculator for a precise prediction. My goal is to find a way for the website to retain the data input from ...

Chrome freezes when an asynchronous ajax request is made using jQuery

Hey there, I'm working on an ajax request that is causing some issues in Chrome. Despite working fine in IE, Chrome freezes for seconds before the timeout event is triggered. Can anyone spot what might be causing this problem? Here is the code snippet ...

Using Stylus and Nib CSS in a secure Node/Express application is causing Chrome to flag insecure JavaScript warnings

System notifications: The website at [...] encountered insecure content from http://fonts.googleapis.com/css?family=Quicksand. as well as The site at [...] showed insecure content from http://themes.googleusercontent.com/static/fonts/quicksand/v2/sKd0EM ...

Tips for reconstructing a path in Raphael JS

I am encountering a unique issue with my implementation of Raphael JS. Currently, I am working on drawing a donut element and seeking advice similar to the content found in this helpful link How to achieve 'donut holes' with paths in Raphael) var ...

Ways to retrieve the marginLeft of an element set with absolute positioning?

Currently, I am attempting to display an information box when hovering over an element with the mouse. The issue I am facing is that the element moves, and I need to determine its left margin. However, the element does not have a margin-left property in ...

Utilize external cascading style sheets (CSS) to style XML data loaded into Flash

Trying to incorporate formatted xml into a flash game has been quite challenging for me. Despite my efforts, the css styling doesn't seem to be applied properly. Below is the content of my stylesheet woorden.css: .f {color:red;} This is the str ...

Repositioning a variable number of divs as the cursor hovers over the target area

Can anyone show me how to generate div elements in a loop using jQuery and change their position with the "mouseover" function? I've tried some code, but the positioning isn't changing correctly. Any suggestions on what needs fixing? var r, g, ...

Failure to trigger jQuery.ajax success function on Windows XP operating system

Snippet: $.ajax({ type: "POST", url: "students/login", data:{"data[Student][email]":_email,"data[Student][password]":_password}, beforeSend: function(){ $("#confirm").text(""); }, error: function (xhr, status) { ale ...

The functionality of IE's .attr disabled feature appears to be ineffective

My function to check if a product is available overnight is not functioning properly in Internet Explorer, although it works fine in other browsers. function checkOvernight() { id = $_2("[name='product']").val(); if(id.length > 0) { ...