$(function() {
var cancelDrag = false;
$(".section").sortable({
connectWith: ".section, .inn_column",
items: '.row',
receive: function(event, ui) {
console.log($(ui.item));
if ($(ui.item).hasClass("inn_portlet")) {
$(ui.sender).sortable("cancel");
cancelDrag = true;
$(this).sortable('cancel');
return false;
} else {
cancelDrag = false;
//$(ui.item).find('input:radio')[1].checked = true;
}
},
start: function(event, ui) {
console.log('start');
},
stop: function(event, ui) {
console.log(cancelDrag);
console.log('stop');
},
update: function(event, ui) {
var newIndex = ui.item.parent().attr('class');
var oldIndex = $(this).parent().attr('class');
console.log(cancelDrag);
console.log(newIndex);
console.log('update');
},
sort: function(event, ui) {
console.log('sort');
},
change: function(event, ui) {
console.log('change');
},
out: function(event, ui) {
console.log('out');
},
over: function(event, ui) {
console.log('over');
},
//handle: ".row-header",
//cancel: ".inn_portlet",
placeholder: "row-placeholder ui-corner-all"
});
$(".inn_column").sortable({
connectWith: ".inn_column, .section",
//items: '.row, .inn_portlet',
//handle: ".row-header",
//cancel: ".row-toggle",
placeholder: "row-placeholder ui-corner-all",
start: function(event, ui) {
console.log('el start');
},
stop: function(event, ui) {
console.log(ui);
console.log(event);
console.log('el stop');
},
update: function(event, ui) {
console.log('el update');
},
sort: function(event, ui) {
console.log('el sort');
},
change: function(event, ui) {
console.log('el change');
},
out: function(event, ui) {
console.log('el out');
},
over: function(event, ui) {
console.log('el over');
},
});
});
body {
min-width: 520px;
}
.section {
width: 170px;
float: left;
padding-bottom: 100px;
border: 1px solid;
margin: 5px;
}
.inn_portlet,
.row {
margin: 0 1em 1em 0;
padding: 0.3em;
}
.row-header {
padding: 0.2em 0.3em;
margin-bottom: 0.5em;
position: relative;
background: #f0f0f0f0;
}
.row-toggle {
position: absolute;
top: 50%;
right: 0;
margin-top: -8px;
}
.row-content {
padding: 0.4em;
}
.row-placeholder {
border: 1px dotted black;
margin: 0 1em 1em 0;
height: 50px;
}
.inn_column {
border: 1px solid;
margin: 5px;
}
.inn_column .inn_portlet .row-header {
background: #fff0f0f0;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
<div class="section" id="s1">
<div class="inn_column">
<div class="row">
<div class="row-header">Outer</div>
</div>
<div class="row">
<div class="row-header">Outer</div>
</div>
<div class="inn_portlet">
<div class="row-header">Inner</div>
</div>
<div class="inn_portlet">
<div class="row-header">Inner</div>
</div>
<div class="row">
<div class="row-header">Outer</div>
</div>
</div>
</div>
<div class="section">
<div class="row">
<div class="row-header">Outer</div>
</div>
<div class="inn_column">
<div class="inn_portlet">
<div class="row-header">Inner</div>
</div>
<div class="inn_portlet">
<div class="row-header">Inner</div>
</div>
</div>
</div>
<div class="section">
<div class="row">
<div class="row-header">Outer</div>
</div>
<div class="row">
<div class="row-header">Outer</div>
</div>
<div class="inn_column">
<div class="inn_portlet">
<div class="row-header">Inner</div>
</div>
<div class="inn_portlet">
<div class="row-header">Inner</div>
</div>
</div>
</div>
</body>
</html>