I am making a program using html, css, angularJs and jQuery. I am not trained in jQuery nor angular, so I am learning on the way.
The idea is to have different screens moving on the browser and the user will be able to move them where he wants so I am using http://jqueryui.com/draggable/.
But I am having an issue I can not find how to solve. Once you add content on the div or resize it the other divs move down (they think the first div is up to them, so they move down to allow him to grow) it makes no sense since the box is not at the place it began (user provably move it to another place on the screen).
I attach my code, you can see how resize the items you have moved still move the ones on it's initial place:
HTML:
<html>
<head>
<title>T1</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="angularJs/angularScripts.js"></script>
<script src="JQuery/"></script>
</head>
<body ng-app="myApp" >
<div class="program" ng-controller="program">
<button class="buttonAddItem" ng-click="addItem();">
item +
</button>
<!-- items -->
<div class="item" ng-repeat="item in items" >
<div >
{{item.name}}
</div>
</div>
</div>
<script>
//mover las ventanas
$(function () {
$(".item").draggable();
});
//cambiar el tamano de las ventanas
$(function () {
$(".item").resizable();
});
</script>
</body>
`
Angular:
var app = angular.module('myApp', []);
app.controller('program', function ($scope) {
$scope.items = [];
$scope.items[0] = {name: "name1"};
$scope.items[1] = {name: "name2"};
$scope.items[2] = {name: "name3"};
$scope.items[3] = {name: "name4"};
$scope.addItem = function ($event) {
var newItem = {name: "newItem"};
$scope.items.push(newItem);
};
$scope.removeMethod = function (id) {
removeItem($scope.methods, "id", id);
};
var removeItem = function (object, key, value) {
if (value === undefined)
return;
for (var i in object) {
if (object[i][key] === value) {
object.splice(i, 1);
}
}
};
var getItem = function (object, key, value) {
if (value === undefined)
return;
for (var i in object) {
if (object[i][key] === value) {
return object[i];
}
}
};
});
CSS:
.item{
border: solid;
width: 30%;
}
Can you say me how to solve it please?