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

The font in my Next.js / Tailwind CSS project starts off bold, but unexpectedly switches back to its original style

I recently integrated the Raleway font into my minimalist Next.js application with Tailwind CSS. I downloaded the font family in .ttf format and converted it to .woff2, but I'm having trouble changing the font weight using custom classes like font-bol ...

Determine the character's position in an input field by tracking mouse movements

I am in need of a way to determine the position of a character in an input field based on mouse movement. For example, if the input field contains the value 'abcde' and I hover my mouse over the character 'a', the position should be ...

Following my ajax submission, the functionality of my bootstrap drop-down menu seems to have been compromised

I'm having an issue with my login page. After implementing Ajax code for the reset password feature, the dropdown menu on the login page doesn't work properly when wrong details are entered and the page reloads. I've tried using the $(' ...

Having trouble with ion-item click not functioning in Ionic 3?

Working on my Ionic 3 project, I have encountered an issue with the ion-item click listener. The scenario is that I am adding text over a canvas and then attempting to change the style of the text (such as font-family, font-size, bold, and italic). The UI ...

Generate a click event on the target page after clicking on an href link

On a source page, there is a collection of links that direct to various documents containing HTML content. Each document has a "print" button within it. I'm looking for a way for clicking on one of the links in the source page to automatically trigger ...

Ways to conceal a div element when the JSON data does not contain a value

If the value in "desc" is empty, then hide <div24> and <popup-desc>. html <div class="popup"> <div class="popup-top" style="background-color: '+e.features[0].properties.fill+';"> ...

Issue with Ajax post redirection back to original page

I'm facing an issue with my ajax call where I send multiple checkbox values to a php file for processing and updating the database. The post request and database updates are successful, but the page doesn't return to the calling php file automati ...

Please enter the text in the field provided at the bottom using IE10

Why is the text inside my input appearing at the bottom in IE10, while it displays in the middle on FF and Chrome? http://jsfiddle.net/PXN2e/2/ input.form-text { color: #999999; font-size: 14px; height: 30px; line-height: 30px; paddin ...

Looking to remove any saved autofill data from your browser? Learn how to do this using either jQuery, HTML,

I've been struggling to remove the autofill data in my browser for days now, but haven't had any luck. I have attached a reference file for your review. Click here to view the attachment ...

How to create a Bootstrap panel that collapses on mobile devices and expands on desktop screens?

Is there a simple way to remove the "in" class from the div with id "panel-login" when the screen size is less than 1199px (Bootstrap's xs, sm, and md modes)? I believe JavaScript or JQuery could be used for this, but I'm not very proficient in e ...

Tips for customizing the CSS file of a React component imported from a UI framework

As I embark on building a large application utilizing React, I find myself navigating the new territory of React philosophy coming from a background of Css+Js+jQuery methods. One key requirement for my project is a reliable UI framework that aligns with Go ...

Retrieve values from numerical fields based on Button Click using jQuery

I have 20 fields (numbered 1-20) with corresponding submit buttons, each field containing different values. I need to retrieve the values of these fields for an AJAX post based on which button is clicked. For example: $(function(){ $("#addCommentButto ...

Exploring the Dynamic Trio: JQuery, Datatables, and the Power

Struggling to populate my datatable dynamically using an ASP.NET web-method written in C#. The method works fine, but the datatable doesn't respond as expected despite numerous attempts. Check out my code snippet: var oTable = $('table.datatabl ...

Interested in using jQuery to trigger the f12 key press?

In my current project, I have successfully disabled the f12 and right click using jQuery. Here is the code snippet: $(document).keydown(function(event){ if(event.keyCode==123){ return false; } else if(event.ctrlKey && event.shiftKey && ...

Unusual issue with jQuery function failing to detect click events

As I delve into my first jQuery function, the primary goal is to assign a form to the function. Upon clicking the submit button, it should perform validation on each :input field within the function. The form is set as the selector for the function: $("f ...

Is there a way to store image URLs in a fashionable manner?

Hey there! I've been working on creating a HTML page that showcases multiple images. Everything is running smoothly on my localhost, but when I try to access it online, the images take forever to load. Any suggestions on how I can cache image URLs in ...

Steps for adding an overlaying image in HTML and SCSS

First step: background-size: cover; Second step: background-size: contain; background-repeat: no-repeat; The third step is what I need: the first background image to be set as cover and the second one as an overlay with no-repeat Currently, my HTML incl ...

Create a function that will repeatedly call itself at specified intervals, increment a variable, and update the class values of elements with an id matching the current value of the

I'm attempting to create a setup that cycles through different images <div id="img_box" class="shadow" onload="imgCycle(1)";> <img id="1" class='opaque imgbox selected' src="media/img ...

Double-click required to toggle button

Here is the code snippet for controlling an LED using a web page. The script, linked to Python, effectively controls the LED. However, there is an issue where the button toggles to the right side (ON position) only after a double click. Upon first click ...

Oops! Looks like there was an error: weight is not defined when trying to calculate BMI with the HTMLButtonElement

I'm currently working on a project to create a BMI calculator following specific instructions. I've managed to follow all the guidelines except one regarding the letsCalculateBMI function. The instruction states: letsCalculateBMI should extrac ...