http://rubaxa.github.io/Sortable/Sortable.js

http://rubaxa.github.io/Sortable/Sortable.min.js
http://rubaxa.github.io/Sortable/ng-sortable.js
http://rubaxa.github.io/Sortable/
https://github.com/RubaXa/Sortable


<script src="js/Sortable.min.js"></script>
<script src="js/ng-sortable.js"></script>
<div ng-sortable="sortableConfig">
<div>1</div>
<div>2</div>
<div>3</div>
</div>

$scope.conponOrderby=function(n){
var json=angular.copy($scope.paramsData);
timer=$timeout(function(){

json.sortJson={};

angular.forEach($scope.sortList,function(v,e){
json.sortJson[v._id]=e+1;

})
console.log("=22222");
$scope.sortList=[];
var currentUrl=baseHref+"coupons/sort/all";
$http({ method:"PUT",url: currentUrl,
headers: { 'Content-Type': 'application/json; charset=UTF-8'},
data:json
}).success(function(data){

});
},n)



}


$scope.sortableConfig = { animation: 750,
onEnd: function(list) {
$scope.sortList=list.models;
$timeout.cancel(timer);
$scope.conponOrderby(2000);
}
};


node:
var sortJson = info.sortJson;

coupons.find(where, function(err, data) {
if (err) return next(err);
data.forEach(function(value, key) {
if (sortJson[value._id]) {
value.order = sortJson[value._id];
value.save();
}

})
res.json(returnData);
});

 posted on 2016-10-09 09:12  jayruan  阅读(741)  评论(0编辑  收藏  举报