0

I know there are lots of questions somewhat related to this, but as I am new to jQuery html, Can't figure out how to do this.

I have a div container(which has already some elements(div) inside it) and I am dropping other divs inside it.

What I want to know is all the divs ID already present in the container at the time of dropping.

What I am adding is a same types of items from a group to the container, Now if I am adding the same item twice I need to know how many same type of items are already present in the container, so I can create its ID as car1,ca2,car3 etc.

I know its a bit confusing, feel free to say, if I can make you understand.

Thanks.

I know there are lots of questions somewhat related to this, but as I am new to jQuery html, can't figure out how to do this.

I have a div container(which has already some elements(div) inside it) and I am dropping other divs inside it.

What I want to know is all the divs ID already present in the container at the time of dropping.

What I am adding is a same types of items from a group to the container, Now if I am adding the same item twice I need to know how many same type of items are already present in the container, so I can create its ID as car1,ca2,car3 etc.

I know its a bit confusing, feel free to say, if I can make you understand.

Thanks.

  $( "#c1 .component-group" )
    .droppable({ activeClass: "ui-state-default",
                 hoverClass: "ui-state-hover",
                 accept: ":not(.ui-sortable-helper)",
                 drop: function( event, ui ) {
                     var draggedImage = ui.draggable.find("img").attr("src");
                     var draggableAdded;

                     for (i =0 to elements in c1 )
                     {
                         if(element dragged == element present )
                            get the id 
                            new_id = id + 1
                            make a new div with new_id and append with the container.
                         }

                         $(event.target).append(draggableAdded);
                     }
           });
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ZAFFY
  • 1
  • 5
  • It'd be less confusing if you post a code sample - doesn't sound like such a hard question so should be able to help if you provide some more context. –  Jun 16 '16 at 09:26
  • can't you just store the dropped elements ID's into an array, and access it whenever you want? – pumpkinzzz Jun 16 '16 at 09:33

1 Answers1

0

If i understood what you are asking for you this should do the trick:

ui.draggable.("#c1 .component-group").serialize()