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 6614877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:23:32+00:00 2026-05-25T20:23:32+00:00

I have two bits of code, nearly the same <div class=favButtonHolder alt={% url inturl

  • 0

I have two bits of code, nearly the same

<div class="favButtonHolder" alt="{% url inturl int.id %}">
        {% if int in user.get_profile.favorites.all %} 
            <div class="favorite favButton" style="display:none;">Favorite</div>
            <div class="favorited favButton">Favorite</div>
        {% else %}
            <div class="favorite favButton">Favorite</div>
            <div class="favorited favButton" style="display:none;">Favorite</div>
        {% endif %}
    </div>

and

<div class="favButtonHolder" alt="{% url inturl result.object.id %}">
    {% if result.object in user.get_profile.favorites.all %} 
        <div class="favorite favButton" style="display:none;">Favorite</div>
        <div class="favorited favButton">Favorite</div>
    {% else %}
        <div class="favorite favButton">Favorite</div>
        <div class="favorited favButton" style="display:none;">Favorite</div>
    {% endif %}
</div>

And some matching jQuery:
$(document).ready(function() {

    // Selecting Favorites
    $('.favButtonHolder').click(function() {
        var container = $(this);

        $.get( container.attr('alt'), {'fav': 1}, function() {
            container.find('.favButton').toggle();
        });

    });
});

For some reason, when I toggle on the first bit of code, it works just fine. It hides the proper div and displays the proper div.

For some unknown reason, when I toggle on the second bit of code, it flips for just a few milliseconds and then flips back (hidden becomes block, and then hidden almost immediately, and vice versa). It is executing the GET, but not toggling properly.

Why would this happen?

  • 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-25T20:23:32+00:00Added an answer on May 25, 2026 at 8:23 pm

    Making an answer out of my comment


    Check your JavaScript files to see if you’ve duplicated the code you posted. If it’s present in two places, when the .click() event fires, two GET requests and two .toggle()s will be triggered, cancelling each other out in respect to the latter. Check your JS files for duplicate code (as you have) and remove it to fix your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two separate (but similar) bits of jQuery code. They both work, but
I have two bits of code. First a standard copy paste from cell A
What would be the best code to have two bits of text in a
I have two Java class files: primegen and primecheck sitting in the same directory.
I have two classes, and want to include a static instance of one class
I have two questions. 1) I found a little gem of code for how
Here is the two important bits. I have a taxpayerID that comes from the
In a web app which I'm building, I have two loosely related bits of
I have the following code which tries to add a class of selected to
Have two folders with approx. 150 java property files. In a shell script, how

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.