Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
A bug I am facing with JqueryUI draggable/droppable

I would appreciate if someone can help me out,

here's my code :

`https://jsfiddle.net/m796a3ud/`

What I want to do is drag an image from these list of Images and be able to get a clone that's draggable, and when I put it inside the box it counts how many images are inside, it works good for the most part but when I try to drag the cloned image in and out of the box a couple of times the clone gets cloned it self which is not what I want, I would really appreciate the help!

thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have to call ui.helper.remove(); on the out event, try this:

$(function() {
    // document.addEventListener('mousemove', function(event) {
    //     console.log($(':hover').hasClass('draggable'))
    // })
    var n = 0;
    $( ".draggable" ).draggable({helper: 'clone'});
        
    $( ".wrong" ).draggable();

    $( "#droppable" ).droppable({    
        accept: ".draggable",
        drop: function( event, ui) {
            console.log(ui.draggable)
            
            console.log($(':hover').hasClass('draggable'))
            var new_signature = $(ui.helper).clone().removeClass('draggable');
            new_signature.draggable();
            $(this).append(new_signature);
           
            if($(new_signature).hasClass("ui-draggable") && !$(new_signature).hasClass("dropped")){
          
                 $(new_signature).addClass("dropped draggable")
                n++;
        $(".count").text("There are " + n + " divs inside parent box detail.");
      

            } 
        },
        out: function(event, ui) {

            ui.helper.remove();

            if($(ui.draggable).hasClass("draggable") && $(ui.draggable).hasClass("dropped")) {
                $(ui.draggable).removeClass("dropped")
                console.log(ui.helper)
            }
            if( n > 0) {
                n--
            }
            $(".count").text("There are " + n + " divs inside parent box detail.");
            
        }
        
    });
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda