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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:57:51+00:00 2026-05-27T20:57:51+00:00

I have draggable items that can be cloned. I wanted each clone to be

  • 0

I have draggable items that can be cloned. I wanted each clone to be unique so each of them can be inserted into our database (with coordinates, which will be done later on).

 $(document).ready(function() {
    cntb1 = 0;
    cntb2 = 0;
    cntb3 = 0;
 $(".droppable").droppable({
    accept: '#b1, #b2, #b3',        
        drop: function(event, ui) {
        if(ui.draggable.attr('id')=='b1'){
                cntb1++;    //counts clones
                $(this).append($(ui.helper).clone());               
                $(".droppable .drag").addClass("component");
                $(".component").removeClass("drag");
                $(".component").resizable({aspectRatio: 'true' }).parent().draggable({ //parent() -> both draggable & resizable work
                        containment: '.droppable', //cursor: 'move', grid: [3,3]                        
                }).attr('id', 'b1c'+cntb1); //change id
                $("#status1").append('b1c'+cntb1);
            }
        else if(ui.draggable.attr('id')=='b2'){
                cntb2++;    //counts clones
                $(this).append($(ui.helper).clone());               
                $(".droppable .drag").addClass("component");
                $(".component").removeClass("drag");
                $(".component").resizable({aspectRatio: 'true' }).parent().draggable({ //parent() -> both draggable & resizable work
                        containment: '.droppable', //cursor: 'move', grid: [3,3]                        
                }).attr('id', 'b2c'+cntb2); //change id
                $("#status2").append('b2c'+cntb2);
            }
        else if(ui.draggable.attr('id')=='b3'){
                cntb3++;    //counts clones
                $(this).append($(ui.helper).clone());               
                $(".droppable .drag").addClass("component");
                $(".component").removeClass("drag");
                $(".component").resizable({aspectRatio: 'true' }).parent().draggable({ //parent() -> both draggable & resizable work
                        containment: '.droppable', //cursor: 'move', grid: [3,3]                        
                }).attr('id', 'b3c'+cntb3); //change id
                $("#status3").append('b3c'+cntb3);
            }

    }
}); 

$(".drag").draggable({ 
            helper:'clone', 
            appendTo: 'body', //para maka drag padung gawas sa accordion
            cursor: 'move' 
            });
$( "#accordion" ).accordion({                   
            autoHeight: false,                  
            collapsible: true,
            active: false
});
});

But the problem is that whenever i create a new clone the ID of the old clone gets replaced with the ID of the new one. I tested it by styling ID’s like this:

        #b1c3{ background:#00FF00; }
        #b1c2{ background:#CCFF00; }

My HTML is like this btw:

    <div id="accordion">
 <h3><a href="#">Buttons</a></h3>   
     <div class="div-table">         
        <div class="div-table-row">
        <div class="div-table-col"><img src="button_final/button_1.gif" id="b1" class="drag"/></div>
        <div class="div-table-col"><img src="button_final/button_2.gif" id="b2" class="drag"/></div>
        <div class="div-table-col"><img src="button_final/button_3.gif" id="b3" class="drag"/></div>
        </div>
          </div>
</div>
<div id="frame" style="border:dotted; height:500px; width:60%; float:left" class="droppable">
<h3 id="status1" style="height:30%;"></h3>
<h3 id="status2" style="height:30%;"></h3>
<h3 id="status3" style="height:30%;"></h3></div>

ps. I assembled everything with the help of people here. I owe you my life!

  • 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-27T20:57:52+00:00Added an answer on May 27, 2026 at 8:57 pm

    This should work for sure,the change is that u have to assign an id at the time of appending it to droppable,previously u were assigning id to all the elements with component class which is wrong in your case.
    so the only change will be :

     $(this).append($(ui.helper).clone().attr("id",'b1c'+cntb1)); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a row where I can drag items into it, and sort them.
I have 2 html elements, 1. <div class=drag>..example.jpg..</div> contains images that can be dragged/cloned/dropped.
I have a set of divs that have been cloned via Jquery ui Draggable/
I have multiple element that are jquery ui draggable, these elements can also be
I have a list of draggable table cells that can be dropped onto a
Having a slight spot of bother... I have a draggable element that can be
in my app, I have a MainActivity that consist of many items that can
I have: String uri = @drawable/myresource.png; How can I load that in ImageView? this.setImageDrawable?
I am trying to create a stage. I have 5 items in a draggable
I have several dynamically generated unordered lists. The <li> 's within them are draggable/droppable

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.