Saritha

Saritha

  • NA
  • 98
  • 26.2k

Trash is not working properly

May 11 2013 3:27 AM


 Hi,


 Trash is not working properly for me...Can anyone please tell me?

here is my code...


<script type="text/javascript">

      $(document).ready(function() {

          //Counter

          counter = 0;

          //Make element draggable

          $(".drag").draggable({

              helper: 'clone',

              containment: 'frame',



              //When first dragged

              stop: function(ev, ui) {

                  var pos = $(ui.helper).offset();

                  objName = "#clonediv" + counter

                  $(objName).css({ "left": pos.left, "top": pos.top });

                  $(objName).removeClass("drag");





                  //When an existiung object is dragged

                  $(objName).draggable({

                      containment: 'parent',

                      stop: function(ev, ui) {

                          var pos = $(ui.helper).offset();

                          //console.log($(this).attr("id"));

                          //console.log(pos.left)

                          //console.log(pos.top)

                      }

                  });

              }

          });

          //Make element droppable

          $("#frame").droppable({

              drop: function(ev, ui) {

                  if (ui.helper.attr('id').search(/drag[0-9]/) != -1) {

                      counter++;

                      var element = $(ui.draggable).clone();

                      element.addClass("tempclass");

                      $(this).append(element);

                      $(".tempclass").attr("id", "clonediv" + counter);

                      $("#clonediv" + counter).removeClass("tempclass");



                      //Get the dynamically item id

                      draggedNumber = ui.helper.attr('id').search(/drag([0-9])/)

                      itemDragged = "dragged" + RegExp.$1

                      //console.log(itemDragged)



                      $("#clonediv" + counter).addClass(itemDragged);



                  }
                  $("#trash").droppable({
                      drop:function(ev, ui) {
                                          accept: "#frame",
                   $(ui.draggable).remove();
                   




                      }
                  });

              }

          });

      });


  




  </script>


After dragging the letters into particular cell from that into trash it's working fine,problem is the letters are in the left side of the puzzle also droppable into trash permanantly.I want only drop the letters from cells into trash.

Thanks,
Saritha