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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:30:49+00:00 2026-05-29T16:30:49+00:00

I have a container with different draggable -elements and there is a list of

  • 0

I have a container with different draggable -elements and there is a list of some “target” divs, where the user can drop the draggable elements.

Example:
Imagine, you have a list of “tags” (House,Computer,Car,..) and a list of some documents as target (all documents are part of the div <div id="doclist">). So the target is to assign the “tags” to the document using drag & drop. By the way, every tag-Div has an unique id (<div id="e34a568b2">)

Code for making the “tags” draggable:

$('#taglist').find('div').draggable(
    {helper: "clone"});

Code for making the documents “droppable”:

$('#doclist').droppable({
        drop: function( event, ui )
                       {tag=ui.draggable;
                        tag.clone().appendTo( this );
                       } });

Until now, this works well.
The Problem is, that right now you can assign the same tag multiple times to same documents.
Example: document 1 can get tag “House” 5 times, Tag “Computer” 3 times.

My target is, that every document can have every tag only one time.

I don’t know, how to solve this problem. Right now, i thnik there are to ways:

1.) expand the “drop” function by walking trough the DOM $(this).find… to see, if there is an element with the same id – in this case, don’t clone&append again. Probably this needs a lot of performance.

2.) use the “accept” feature of the draggable widget. But i don’t know how to use this at this situation.

Thank you for any kind of help.

  • 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-29T16:30:52+00:00Added an answer on May 29, 2026 at 4:30 pm

    First, you should make sure to never have two elements with the same id in the page. So when dropping, you want to change the id in some manner, e.g.:

    $('#doclist').droppable({
      drop: function( event, ui ) {
        tag=ui.draggable;
        tag.clone().attr("id", "copy-" + tag.attr("id")).appendTo( this );
      }
    });
    

    Next, indeed you could use accept and checking the DOM. Don’t worry, I don’t think it will be too resource intensive. Something like:

    $('#doclist').droppable({
      drop: function( event, ui ) {
        tag=ui.draggable;
        tag.clone().attr("id", "copy-" + tag.attr("id")).appendTo( this );
      },
      accept: function(draggable) {
        return $(this).find("#copy-" + draggable.attr("id")).length == 0;
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I contain two different types in a collection? For example, can I have
I have a container div that holds two internal divs; both should take 100%
I have these container objects (let's call them Container) in a list. Each of
Is there a way to reassign agents to a different container or will I
i have to objects / elements. one is [ 4 images with different ids
As the title explains, I have one container div, containing two floating divs of
i have a input textfield within a container. This container is draggable, but now
I have a container and I have #info holding my h5 text. How can
What am I doing: I have a container class named Os , that can
I have a project to draw relationships between different elements determined on a sheet.

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.