Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

133
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda