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

136
Visualizações
Using Sortable list of Jquery , when I try to change the rendering list in the stop event rendering goes haywire

JS code:

$scope.addFunction = function(){
        $scope.dummyList1 = [];
    let n=4;
    for(let i=0;i<n;i++)
    {
        $scope.dummyList1.push({key:i});
    }
};

$scope.addFunction();

$scope.initializeSortable1 = function(){
        let myArguments1 = {};
        $( ".sortable3" ).sortable({
            stop : function( event, ui ) {
                if (this === ui.item.parent()[0]) {
                     if (ui.sender == null) {
                        myArguments1 = assembleData(this);
                        myArguments1;
                    }
                }
                var newList = [];
                for(var i=0;i<myArguments1.length;i++){
                    newList.push({key:myArguments1[i]});
                }

                $scope.dummyList1 = newList;

            }
        });
    };

    $scope.initializeSortable1();

html code(angular):

                    <div>
                        <div class="sortable3">
                            <div ng-repeat="xx in dummyList1  track by $index" id="{{xx.key}}" >
                                <div>{{xx.key}}</div>
                            </div>
                        </div>
                    </div>

creates a sortable list as: 0 1 2 3

now when I drag and drop 0 over 3, it is expected the list becomes: 1 2 3 0

but instead it becomes: 1 0 2 3 or something else at times.

now on removing the code

            var newList = [];
            for(var i=0;i<myArguments1.length;i++){
                newList.push({key:myArguments1[i]});
            }

            $scope.dummyList1 = newList;

from the stop function, the sorting works as expected. but I require this piece of code as I need to update the parent list =>$scope.dummyList1 responsible for rendering on UI on every update.

please point out the issue or suggest a suitable alternative.

Thanks

about 4 years ago · Juan Pablo Isaza
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