javascript - Select only those elements which has changed there positions after sorting by .sortable -


i have 5 divs . ordered per priority.i sorting there positions using jquery sortable. there way know position of divs has changed there position during sorting.

html section:

<body>    <div id="sortable">     <?php foreach($data $row){ ?>     <div class="alert alert-success" data-id="<?php echo $row['id'] ?>" role="alert"><?php echo $row['div-name']; ?></div>     <?php } ?>   </div>  </body>   sctript part:  <script>   $( function() {     var lastmoved = null;     $("#sortable div").mousedown(function(){         lastmoved = this;     });     $("#sortable").sortable({       start: function(e, ui) {         //alert("");         // console.log("prev: "+$(this).attr('data-id'));       },       update: function(event, ui) {         alert("moving: "+$(lastmoved).attr("data-id"));         alert("moved to: "+parseint($(lastmoved).index()+1));       },       stop: function(event, ui) {         var data = "";          $("#sortable div").each(function(i, el){             var p = $(el).attr("data-id").tolowercase().replace(" ", "_");             data += p+"="+parseint($(el).index()+1)+",";         });         console.log(data.slice(0, -1));      }     });   } );   </script> 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -