The problem of jQuery failing to load the project within the slideshow container div

The project text appears duplicated and the header when an image is clicked. However, the 'Back to Portfolio' button and header buttons do not seem to work.

Even if you return to the 'Portfolio' page, the project text continues to appear.

html

<li style="height:393px;" data-src="http://www.janinejauvel.com/wp-content/uploads/2012/09/editorial-1-rwd-magazine.png">
<span class="cover" style="width:308px;height:0px;background-image:url('http://www.janinejauvel.com/wp-content/uploads/2012/09/bg-white.png')"></span>
<hgroup style="width:308px;height:393px;background-image:url('http://www.janinejauvel.com/wp-content/uploads/2012/09/bg-white.png')" data-project="test/dirty-fashion">
                        <div>
                            <h3>Editorial I</h3>
                            <span class="dash">&mdash;</span>
                            <p>RWD Magazine</p>
                        </div>
                    </hgroup>
                </li>

script.js

// Once the project is loaded into the slideshow container div
                $('#slideshow-container').load('' + $hgroup.attr('data-project'), function() {
                    // bind slideshow
                        slideshow.render();
                        $('section#work').css('margin-top', '0px');
                });

            });


$(document).ready(function() {

    hattie.init();
    hattie.clickEvents();
    hattie.loadImages();

});

$(window).resize(function() {

    // get the currently active project, if there is one

    if ($('#slideshow').length > 0) {


        var activeProject   = $('#slideshow').attr('class');

        // trigger click
        $('hgroup[data-project="'+ activeProject + '"]').trigger('click');

    }


});

Answer №1

Consider making the following adjustment:

$('#slideshow-container').load('' + $hgroup.attr('data-project'), function() {

Change it to:

$('#slideshow-container').load('' + $hgroup.attr('data-project') + ' #content', function() {

By doing this, only the content div from the specified URL in $hgroup.attr('data-project') will be loaded.

Answer №2

When using the load function, you are essentially bringing in an entire HTML page into that specific div which includes the header element.

Take a closer look at the contents of the page being loaded:

If all you need is the content, consider exploring how to load page fragments.

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 are the best methods for implementing runtime type checking in JavaScript?

Utilizing either TypeScript or Facebook's Flow (type), I am empowered to statically assign types to variables like this: function add (x: integer, y: integer) { ... } Both TypeScript and Flow are able to identify and prevent incorrect invocations su ...

Add data from the array to the specific element in the DOM using its corresponding index by leveraging jQuery

Imagine having three divs in your HTML file: <div> <h2>This is div 1</h2> </div> <div> <h2>This is div 2</h2> </div> <div> <h2>This is div 3</h2> </div> Now, you also hav ...

Clip the text with ellipsis if it exceeds the limit and show the file

Currently working on an upload feature where I need to show the name of the uploaded file. File Name.txt The problem arises when the name is too lengthy, resulting in a display like this: File Name Is Too Long...txt I attempted to solve this by implement ...

Incomplete test on position fixed in Modernizr

Although Modernizr is a valuable tool, the example test for position: fixed has some shortcomings: iOS 4 and below return true, even though they do not actually support position: fixed Opera on Windows returns false, despite its support for position: fix ...

What could be the issue with the nodeValue property?

// html <div>Welcome Everyone!</div> // JavaScript var textElement = div.firstChild; textElement.nodeValue = "Hello Everyone"; Here is the example: example Why is it not possible to modify the text content? ...

Organize items without consideration of their dimensions

I am in the process of creating an alphabetized list of categories, from A-Z. I am utilizing ul and li elements to achieve this. My goal is to have the elements displayed consecutively, regardless of their height. While my current code successfully arrange ...

Steps to connect my CSS with my HTML in a website hosted on GitHub

I am experiencing an issue with my website hosted on Github pages. It seems to be unable to read the CSS file that I have linked to it. Here is a snippet of my HTML code: <!DOCTYPE html> <link rel="stylesheet" type="text/css" href="https://githu ...

Use jQuery to send a variable value to a MySQL database by making a POST

Utilizing ajax/json, I fetch a random row from a mysql-server using PHP. The different data obtained from the random row is stored in variables. $.ajax({ url: 'api.php', data: "", ...

I am interested in utilizing Sequelize, Vue, and Node to implement a query that filters data once it is retrieved to display on my view

Within my project, there's a table tracking user responses to a quiz. By utilizing the following query, I've successfully retrieved all the information from that table and stored it in my TotalQuizResponses array for display: this.totalQuizRespon ...

Implementing a tracking mechanism

My goal is to incorporate a counter into this feature. When a number is clicked, the message should read "You've selected 1 out of 5," indicating that the user needs to choose 5 numbers. If the same number is clicked again, it should deselect and reve ...

Remove parent state using a child component

I currently have two class-based components set up. For the Parent Component: App import React, { Component } from 'react'; import Navbar from './Navbar'; import SearchBar from './SearchBar'; class App extends Component { ...

Sorting information according to a set of strings

My current challenge involves filtering a data set of recipes based on an array of inputs. const [cuisineInput, setCuisineInput] = useState(""); const [cuisineFilter, setCusineFilter] = useState<Filter[]>([]); const [filteredResults, setFilteredRe ...

Unable to insert data into database using javascript

I'm encountering an issue with my node.js code and I can't seem to figure out the root cause. Can someone lend me a hand? When I try to add multiple inputs from an array, it throws an error in node.js and fails to save the data into my database. ...

Create a custom Angular directive that allows you to replace tags while inserting the template

I have created a custom directive that can take templates based on the attribute provided. Check out the Plnkr example JS var app = angular.module('app', []); app.directive('sample', function($compile){ var template1 = '<d ...

Tips for utilizing the latest Vue features within a single file component

Currently in the process of learning Vue.js, I've encountered a small problem: I have a single file component containing an array of checkboxes. While referring to the documentation on working with multiple checkboxes, I found that the provided exampl ...

Utilize the success() callback in JQuery Ajax when handling a response that is null

Within my website application, users have the ability to invite other users to participate in their projects. By entering an email address, a request is sent to the server via post method to check if the user exists. If the user is found, it will return th ...

Encountered a 400 error when sending a date to the web service using ajax in JSON format

Working on a UI project where I need to send form data from an HTML page to the server in JSON format using AJAX to insert the data into the database. I have four fields: Project name: xxx Start date: DD-MM-YYYY End date: DD-MM-YY HTML file <input typ ...

How can I create a list similar to the one on the Angular Material documentation website?

Visiting the Agular Material website (https://material.angularjs.org/#/), you will notice a sidebar with a collapsible list. By clicking on certain items, such as DEMOS, additional subitems are revealed. I want to implement this feature into my web applic ...

How white space manipulation is leading to div stacking in Pure CSS

I am currently utilizing Pure CSS to design a website, but I have encountered an issue. Whenever there is white space between nested grid elements, it disrupts the layout and causes the last div to move onto the next line. In order to troubleshoot this pro ...

The process of retrieving child data from a JSON object

I have a JSON object that I am attempting to iterate through, which is being returned via a Netsuite script. The JSON object contains some child elements. I am specifically trying to access the caption for data under "classnoheirachy - name", but I am un ...