"use strict";
var app = ons.bootstrap("myApp", ["onsen"]);
app.controller("page1Controller", ["$scope", function($scope) {
$scope.table = [
{ id: "1", name: "戸崎", color: "#8888ff" },
{ id: "2", name: "ルメール", color: "#88ff88" },
{ id: "3", name: "デムーロ", color: "#ff8888" },
{ id: "4", name: "川田", color: "#ffff88" },
{ id: "5", name: "福永", color: "#ff88ff" }
];
ons.ready(function() {
$("#sort-list").sortable({
axis: "y",
tolerance: "pointer",
update: function(e, ui) {
var arrayId = $("#sort-list").sortable("toArray");
var table = [];
for (var i = 0; i < arrayId.length; i++) {
for (var j = 0; j < arrayId.length; j++) {
if (arrayId[i] == $scope.table[j].id) {
table.push($scope.table[j]);
break;
}
}
}
$scope.table = angular.copy(table);
}
});
$("#sort-list").disableSelection();
});
$scope.$on("$destroy", function(e) {
$scope.table = [];
});
$scope.checkTable = function() {
console.log("----------");
for (var i = 0; i < $scope.table.length; i++) {
console.log($scope.table[i].name);
}
};
}]);