Styling is lost in FancyBox popup when loading Partial View

I've been attempting to incorporate a partial view into my MVC project using fancybox. It seems to be loading the content correctly, mostly anyway, as it tends to cut off part of the page and loses all styling from the view upon loading.

Even after including CSS files in my partial view, I still can't seem to get it to work properly.

The structure of my partial view is as follows:

@model ApprovalSystem.ViewModels.RequestDetailViewModel
@section styles
{
    <link href="~/Content/Site.css" rel="stylesheet" />
    <link href="~/Content/material.min.css" rel="stylesheet" />
    <link href="~/Content/jquery.fancybox.min.css" rel="stylesheet" />
}
//CONTENT HERE - Not providing it all as it is quite large. Classes and all remain in the partial view though so cannot see that being an issue.
@section scripts
{
    <script>
        $(document).ready(function () {
            $('[data-fancybox]').fancybox({
                maxWidth    : 800,
                maxHeight   : 600,
                fitToView   : false,
                width       : '70%',
                height      : '70%',
                autoSize    : false,
                closeClick  : false,
                openEffect  : 'none',
                closeEffect : 'none'
            });
        })
    </script>    
}

The link I use to open the fancybox is:

<a data-fancybox href="@Url.Action("DetailPartial", new { id = Model.Request.ParentRequestId })" class="mui-btn mui-btn--fab mui-btn--small fancybox.ajax">@Model.Request.ParentRequestId</a>

And this is the controller method used to return the partial view:

public async Task<ActionResult> DetailPartial(int id)
{
    var request = _uow.RequestService.Get(id);
    var currentUser = await AzureGraph.GetUser();
    ViewBag.CurrentUser = currentUser.DisplayName;
    ViewBag.NextApprover = _uow.ResponseService.Get().Where(r => r.RequestId == id && r.ResponseStatus == RequestStatus.NotProcessed).Select(r => r.Responder).FirstOrDefault();
    RequestDetailViewModel viewModel = new RequestDetailViewModel()
    {
        Request = request
    };

    if (request.FolderId != null)
        viewModel.Attachments = await AzureGraph.GetFileSystemObjects(request.FolderId);
    else
        viewModel.Attachments = new List<FSObject>();

    return PartialView("DetailPartial", viewModel);
}

I'm currently stuck and any assistance would be highly appreciated.

UPDATE - Added screenshot

https://i.stack.imgur.com/GYvYY.png

Answer №1

Successfully resolved this problem by identifying that the lack of layout in the partial view was causing sections not to load properly. I remedied this by creating a simple layout for partial views, resulting in the expected functioning.

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

What is the process for changing the text in a text box when the tab key on the keyboard is pressed in

When a user types a name in this text box, it should be converted to a specific pattern. For example, if the user types Text@1, I want to print $[Text@1] instead of Text@1$[Text@1]. I have tried using the keyboard tab button with e.keyCode===9 and [\t ...

I have successfully implemented ngCordova local notifications, but now I am looking for a way to make it trigger for each individual

Is there a way to trigger a notification on every logged-in user's mobile device when a value is changed and saved in Firebase? Currently, I am able to send a local notification using ngCordova when a user enters text in an ionicPopup with textarea. H ...

Component rendering based on conditions is not working properly when using Next.js, especially on the initial load

While utilizing Ant Design and a Custom Stylesheet, I have encountered an issue where the style appears broken upon first load. However, if I navigate to another page and return to the original broken page, it displays correctly. This problem only occurs d ...

Is it possible to implement a setInterval on the socket.io function within the componentDidMount or componentDidUpdate methods

I'm currently working on a website where I display the number of online users. However, I've encountered an issue with the online user counter not refreshing automatically. When I open the site in a new tab, the counter increases in the new tab b ...

Is there a regular expression that can identify whether a string is included in a numbered list?

Struggling with creating a regular expression to determine if a string is part of a numbered list like those in word processors. Need it to return true only if the string starts with a number, followed by a full stop and a space. Easy for single or doubl ...

What is the best way to ensure that table cells containing images resize without any issues?

I need help with centering and resizing an image on a screen. The image is divided into small images within cells, but I can't seem to get it right. Despite trying various solutions and spending hours resizing the table and images, the final output a ...

Combining broken down values within a loop

Take a look at this image, then review the code I've provided: function addNumbers() { var inputList = document.getElementById("listInput").value.split(" "); for(i = 0; i <= inputList.length; i+=1) { document.getElementById("resul ...

Dealing with ReactJs Unhandled Promise Rejection: SyntaxError - Here's the Solution

Struggling to use the Fetch API in ReactJS to retrieve a list of movies. Encountering an issue, can anyone offer assistance? fetch("https://reactnative.dev/movies.json", { mode: "no-cors", // 'cors' by default }) ...

Getting the final element in Selenium Webdriver with JavaScript

When I create a script to confirm the successful addition of an element, I always find that the added element is positioned at the end of the page or becomes the last element in a different div. In this case, I am utilizing selenium webdriver and javascrip ...

Switching the default z-index for child elements within an HTML container

According to the specification, elements are typically drawn "in tree order" for in-flow, non-positioned elements of similar block level or float status and identical z-index. This means that elements declared last in the HTML markup appear on top. But wha ...

Customizable Button component featuring background image options

Need help with creating a versatile Button component in React that can easily accommodate different sizes and shapes of background images? This is how my current implementation looks like - Button.js const Button = ({ url }) => { const inl ...

Modify the onerror function of the image tag within the onerror function

Here is a way to display images using the img tag: If 1.jpg exists, show 1.jpg. If not, check for 2.jpg and display it if it exists. If neither 1.jpg nor 2.jpg exist, display 3.jpg. <img src="1.jpg" onerror="this.src='2.jpg'; this.oner ...

I'm perplexed as to why my webpage displays differently across various browsers

Currently, I am utilizing the Yahoo CSS reset and all my CSS is based on pixel values rather than relative units like ems. Interestingly, there seems to be a discrepancy in the position of the bottom right corner of the form-containing div between Chrome a ...

"Unlocking the Power of jQuery and jTemplates: A Guide to Extracting Accurate Values

I am facing challenges in configuring the correct format for jTemplates and could really use some assistance. My setup includes an ASP.NET page with a WebMethod that returns data to jQuery. The data is then supposed to be processed by jTemplates, but I am ...

Executing Multiple AJAX Functions with when()

My goal is to use jQuery's when() method to run multiple Ajax functions upon form submission. The plan is to wait for these functions to finish and then finally submit the form. However, it seems like my code is not working as intended: $('form[ ...

What is the correct method for formatting text spacing?

A few months ago, I dabbled in web design and created a basic website. Now, I'm revisiting it to clean up the layout and make it more visually appealing. I initially used non-breaking spaces to separate paragraphs, but I know that's not optimal. ...

Using async await in node.js allows you to bypass the need for a second await statement when

As I dive into using await async in my Node.js ES6 code... async insertIngot(body, callback) { console.log('*** ItemsRepository.insertIngot'); console.log(body); const data = await this.getItemsTest(); console.log('*** ge ...

Animate the toggling of classes in jQuery

Here is a code snippet that I came across: $('li input:checked').click(function() { $(this).parent().parent().toggleClass("uncheckedBoxBGColor", 1000); }); This code is functioning correctly when the element is clicked for the first time. I ...

The destination where data is transmitted via POST to a PHP file using the HTTPRequestObject.send method

Can anyone help me figure out where the HTTPRequestObject stores strings that I have sent using the "POST" method to a PHP file? I have checked both the $_POST and $_REQUEST arrays but cannot find them. This is how I am sending the data from JavaScript: ...

What is the best way to submit a form using PHP to send an email, implement Ajax for seamless transitions, and display a message next to the form without any screen refresh?

Upon clicking the submit button, I am looking to achieve two things: (1) Sending the form data via email using PHP without refreshing the page. (2) Displaying a thank you message next to the form utilizing Ajax. Most of the functionality is in pl ...