Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1108883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:09:00+00:00 2026-05-17T02:09:00+00:00

I have a menu made with HTML, using a simple UL with lots of

  • 0

I have a menu made with HTML, using a simple UL with lots of LIs. Each item contains a link with class “primary”. When a list item (anywhere in a list item – not just the text) is clicked, jquery checks to see if the item contains a link with class “primary”, and if so it loads the specified page into a hidden div (which I refer to as temporary, even though its not actually temporary…) and then extracts certain parts of the new page to set as the html for parts of the visible page. For example it takes “.temp .content” and places that in “.content”. It basically extracts the html, sets the html of “.temp” to nothing (otherwise the line $(“.content”).html(newhtml); will set the html of the “.content” within the temporary div) and then sets the html of the original content div to newhtml.

I have a slight problem however. It seems that it sometimes makes the div go blank, sometimes it takes two clicks to load a page and sometimes I can click item 1, then click item 2 and it instantly loads the content from item 1 (i.e. that which is displayed in the content div of the page which is loaded by item 1).

In fact I can make a “chain” – click items 1, 2, 3, 4 and then 1 and 2 again and I see blank, content for items 1, 2, 3, 4 and 1.

Does anyone have any clue as to whats going on here?

Many thanks in advance.

Regards,

Richard

In reply to Peter Ajtai (I have tried to shorten it as much as possible – it is actually much much more complex than this as I have a 3 col layout and a fix to make all 3 columns shaded to the same height – but I think all the essential stuff is here)…

Basic structure of the page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        //jquery includes
        $("li").click(function () {
            var url = $(this).find("a.primary").attr("href");
            if (url != "" && url != null) {
                $(".temp").load(url);
                var newhtml = $(".temp .content").html();
                $(".temp").html("");
                $(".main-col").html(newhtml);
            }
        });
    </head>
    <body>
        <div class="wrapper">
            <div class="leftmenu">//left menu stuff here, in the following format:
                <ul> 
                    <li class="header">Content Management List</li> 
                    <li><a class="primary" href="/Administration/List.aspx?subitem=range">Ranges</a></li> 
                    <li><a class="primary" href="/Administration/List.aspx?subitem=collection">Collections</a></li> 
                </ul>
            </div>
            <div class="content"></div>
            <div class="temp"></div>
        </wrapper>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:09:00+00:00Added an answer on May 17, 2026 at 2:09 am

    I think you should just catch the ajax response in your success handler function and put it where it needs to go the first time around. Doing multiple DOM inserts for the same content is

    a) slow and cumbersome, and
    b) probably where your issue is coming from.

    Most likely (without seeing your code) you’ve got some duplicate id on some element somewhere.

    If you need to insert content returned from the server into separate locations in the document, consider changing your server response to JSON and put the two HTML strings in different array elements.

    UPDATE
    From your example it looks like you are just loading content into .main-col if so you could make a new server method that only serves up a view with content that belongs inside main-col, and then do this:

        $("li").click(function () {
            var url = $(this).find("a.primary").attr("href");
            if (url != "" && url != null) {
                $(".main-col").load(url);
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a menu.html.erb page in layout folder i am using <body> <%=render
I've made a two level menu using CSS and HTML (ul's etc). What I
I have a menu that is built using its own AS3 class, when a
I have a vertical menu in my system which is basically made of HTML
I have an HTML list, like millions of others I have made ...and the
I have a HTML template which I made a typo3 template of, using automaketemplate.
I have dropdown menu and its made via a list and position absolute, however
I have a drop down menu made with Jquery. Right now, if you hover
I have a sliding div menu made with jQuery, but you have to click
I recently made a menu screen to my cocos2d app where I have attached

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.