Customizing Fancybox 2 for AJAX Requests

I am faced with a situation where I have 2 files, namely index.htm and inner.htm.

My goal is to load a specific div from inner.htm into index.htm using Fancybox 2. After exploring various options, I decided to employ AJAX for this task. However, the issue arises when the AJAX request inherits the parent CSS, whereas I want inner.htm to utilize its own CSS styling.

Initially, I tried using an iFrame which allowed me to maintain inner.htm's original CSS, but it did not provide the functionality to load a specific DIV element.

Below are the key points of my dilemma:

Using AJAX: - Specific div from inner.htm can be loaded - However, it adopts the parent CSS instead of its own

Using iFrame: - Unable to load a specific div, only the entire inner.htm page - Maintains its own CSS, thus not inheriting from the parent as desired

Any assistance or guidance on resolving this would be highly appreciated. Thank you!

To clarify further, in my implementation with Bootstrap, when I refer to "inner.htm should use its own CSS," I mean that it should apply its own bootstrap.css to fit within the modal box properly. Presently, it is inheriting the parent's bootstrap.css causing display issues (like horizontal scrollbar appearing).

Therefore, my objective is for inner.htm within the modal box to utilize its own col-md-4 class rather than the parent's. I hope this explanation clarifies the situation. Thank you very much! :)

Answer №1

Include the CSS in the parent CSS to ensure it gets loaded properly.

Check your code and insert the class that is required for the fancybox popup, such as:

.fancybox-iframe .your-div{}

I believe this should resolve the issue.

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

Determine the maximum size of a specified number of square divs that can fit within responsive parent divs

I am working on creating a grid of square divs inside a container with variable height and width. The number of square div's is predetermined. All square divs will have images with the same dimensions (similar to the example). They should align left ...

Guide on incorporating a JS file in a React application

I recently obtained a template for my website that includes the following JS file which is being called from my React component. !(function($) { "use strict"; // Hero typed if ($('.typed').length) { var typed_strings = $(&quo ...

Updating Ajax Data within a LoopExplanation: In this scenario, we

Here is my AJAX function: function updatePrice(id, prid, divid, key, name) { $.ajax({ type: "POST", data: "aid=" + id + "&prid=" + prid, url: '<?php echo base_url('grocery/onchange')?>&a ...

Unable to extract data from my xml reply

I've been trying to extract a value from an XML response, but I keep getting null. What am I missing? $.ajax({ method: "GET", url: "fphub01-prd.tc.workstreaminc.com/hub/custLookup/", data: { emailAddress: email } }).done(function(msg) { ...

What are the best methods for maintaining the appearance of my website when resizing my browser window?

I am replicating the Twitter profile page, but I am facing an issue where the text and images get jumbled together whenever I resize my browser. This results in a messy appearance of the page. How can I ensure that the text and images stay in the same rela ...

How to place an image in the bottom right corner using CSS

Does anyone know how to position an image in the bottom right corner of a div? I have tried using margin-right and padding-right with 0px on the img tag, but it does not seem to work. The black lines indicate that I do not need that space Here is my Cod ...

Animating the text color of JavaFX tabs

Can you help me figure out how to resolve the issue with the lack of animation? All tab text should be in hexadecimal colors like the ones listed below: private final String[] textColors = { "#FF0000", "#FF3300", "#FF6600", ...

Conceal the Div containing the specified class

I was hoping to hide the first DIV if the second DIV is displayed on the front end, and vice versa upon page load. If the first DIV is set to 'block,' then the second DIV should be set to 'none.' And If the second DIV is set to &apos ...

Step-by-step guide on achieving rounded borders with a gap:

Struggling to design blocks and elements with rounded corners that have a gap between the corner and the straight line. It's proving to be quite challenging :) Additionally, I need to create buttons that look like this, and If CSS alone doesn' ...

Div slicing with CSS

Is it possible to slice a div from either side, for example, taking a portion of the left side and making it transparent while keeping everything else in place? For instance, if there is a div named "box" with CSS styling: #box { width:100px; heig ...

Ways to assign the value of an alert to an element

Within this piece of code, my intention is to retrieve the alert value and apply it to an element. Description: The AJAX code I have written checks for values in a database, fetches new values from the database, and then displays these fetched values in a ...

Upgrading the entire document's content using jQuery

I am dealing with an ajax response that provides the complete HTML structure of a webpage, as shown below: <!DOCTYPE> <html> <head> <!-- head content --> </head> <body> <!-- body content --> </b ...

CSS and the best practices for button styling in a navigation bar

My friend and I are facing a CSS issue while working on a webpage together. We both have limited experience with HTML and CSS. Here's the code snippet in question: .nav li { margin: auto; display: inline-block; color: white; padding: 10px; font ...

CSS creates captivating image hover transitions with span elements

<a href=""><img src=""><span>content</span></a> When I hover over the image, the content within the span appears using relative positioning with display set to none and absolute positioning in the span tag. My query is regard ...

Assign a zip code to a form for visitors and clients in the WooCommerce platform

The primary purpose is to validate a visitor's postcode and display various messages based on it. I referred to this thread for setting the shipping code: Set shipping postcode early before add to cart in WooCommerce I have successfully created an AJ ...

Guide on organizing items into rows with 3 columns through iteration

Click on the provided JSFiddle link to view a dropdown menu that filters items into categories. Each item is stored as an object in an array for its respective category. Currently, all items are displayed in one column and I want to divide them into three ...

"Is there a way to remove the additional space beneath items in a display flex box layout created with

This section was designed using Bootstrap and displayed as flex. However, some items seem to have extra space: My goal now is to remove the extra space underneath the items like this: Smaller items will now be resized to match the larger items, elimi ...

PHP not receiving posted value from $.ajax() function

My Ajax post request seems to be causing an issue with the PHP script as the post data is not being received correctly. Whenever I try to execute it, I receive a 500 internal server error along with "XHR failed loading: POST". This is a snippet of my Java ...

How can a fixed size block and a responsive block be aligned next to each other?

I am looking to create a centered table that is 900px wide with one row and two cells. The right cell should always be 200px wide, while the left cell should fill up the remaining space. However, I am facing an issue where the right cell jumps below the le ...

Issues with loading SASS or source maps arise when dealing with nested structures

After reorganizing my SASS files into a nested structure, I encountered an issue where inspecting elements in Chrome led me to incorrect source maps. For instance, when trying to inspect a button, instead of being directed to the _buttons partial as expect ...