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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:41:49+00:00 2026-06-08T23:41:49+00:00

Sorry, this may be a long one so please bear with me. I have

  • 0

Sorry, this may be a long one so please bear with me. I have three sortable (jqueryUI) lists. List all-colls-list, coll-selected-list and coll-grouped-list. I can put items of list all-colls-list into coll-selected-list and coll-grouped-list.

So for example, I can put ‘list item’ into both coll-selected-list and coll-grouped-list at the same time, and the item will be retained in all-colls-list. When the item is added to coll-selected-list, a class name “selAdded” is attached to the list item in all-colls-list. When an item is added to coll-grouped-list, a class name ‘groupAdded” is attached to the list item in all-colls-list.
ex:

<li class"selAdded">Blah blha</li> OR
<li class"groupAdded">Blah blha</li> OR (when item is put in both lists)
<li class"selAdded groupAdded">Blah blha</li>

When I remove the item from either coll-grouped-list or coll-selected-list, it removes the respective class name for that item in all-colls-list. However, if two class names are present, and I remove only one, for some reason, it removes both!
So, if I were to remove “selAdded” from <li class"selAdded groupAdded">Blah blha</li>
it seems that it only leaves <li>Blah blha</li>

I’ve made a fiddle here http://jsfiddle.net/noscirre/xf8j2/

This is my code that removes the class name:

if ($("#all-colls-list li:contains(" + itemName + ")").hasClass("selAdded")) {
                $("#all-colls-list li:contains(" + itemName + ")").removeClass("selAdded"); }

and this is the code that checks for the existence of the class once it has been removed:

receive: function (event, ui) {
                alert($(this).attr('class'));
                if ($(this).hasClass("groupAdded") && $(this).hasClass("selAdded")) {
                    alert("both");
                    //Do nothing
                }
                if ($(this).hasClass("groupAdded") && !$(this).hasClass("selAdded")) {
                    alert("group"); //Do nothing
                } 
                if (!$(this).hasClass("groupAdded") && $(this).hasClass("selAdded")) {
                    alert("sel"); //Do nothing
                }
                if (!$(this).hasClass("groupAdded") && !$(this).hasClass("selAdded")) {
                    alert("none"); //Do nothing
                }
            }

Any help would be much appreciated

  • 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-06-08T23:41:52+00:00Added an answer on June 8, 2026 at 11:41 pm

    It looks like the classes are being added and removed as you’re wanting, but the code that’s checking their existence isn’t working properly. When you’re checking for the classes, $(this) is referring to the parent <ul> rather than the <li> and so shows ‘none’, because the <ul> has neither the selAdded nor the groupAdded class.

    I was using Chrome’s inbuilt inspector to look for the classes while I was dragging things around in your fiddle. I used console.log($(this)); so I could have a look in the error console to be sure what was $(this) was actually referring to at that point in the code.

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

Sidebar

Related Questions

Sorry for the insanely long title, I find this one hard to sum up.
This may seem like a silly question if so sorry =] Ok i have
this post is a long one sorry for that but the problem is complex
First, sorry this is so long. I probably don't need all the code, but
Hi Folks, First of all sorry, this is going to be a moderately long
Sorry, this may or may not be a programming question directly, but I am
Before I start this may be hard for some people to understand. Sorry. I
Sorry this is a basic question, but all my research just barely missed answering
Sorry this is probably super basic. But in all my javabean examples, I've not
long time listener first time caller... I have this function (I don;t recall where

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.