After my lack of success with my previous post, I followed a suggestion and used Bootstrap's Dashboard example as a base, unfortunately with no success.
The aim is a page with a sidebar (col-md-3) that contains panels with all unsorted students (in small panels each), and a main area (col-md-9) that contains different groups (larger panels), in which the students can be dragged and dropped with JQeryUI Sortable. This screenshot shows the concept.
This works fine, except for one problem: while the sidebar does not have a horizontal scrollbar (even when selecting "overflow-x: auto"), it seems to become bigger when trying to drag a panel out from it. This screenshot at the moment when I am dragging the fourt panel from above shows the problem.
Here is a streamlined version of the code:
CSS:
<link href="/static/css/bootstrap.css" rel="stylesheet" media="screen">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
@media (min-width: 768px) {
.sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
padding: 20px;
overflow-y: auto;
}
}
</style>
HTML:
<div class="container">
<div class="row">
<div class="col-sm-4 col-md-3 sidebar">
<div class="unsortedList panel panel-default">
<div class="panel-heading">
Not assigned
</div>
<div class="panel-body">
<ul id="0" class="list-unstyled connectedLists">
<li class="panel panel-primary innerpanel" id="student_1_id">
<input type="hidden" name="student_1_id" value="0">
<div class="panel-body">
Student 1 Name
</div>
</li>
<li class="panel panel-primary innerpanel" id="student_2_id">
<input type="hidden" name="student_2_id" value="0">
<div class="panel-body">
Student 2 Name
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-8 col-sm-offset-4 col-md-9 col-md-offset-3 main">
<div class="col-md-4 col-sm-4 col-xs-5" id="panel_1">
<div class="panel panel-default outerpanel">
<div class="panel-heading">
Group 1
</div>
<div class="panel-body">
<ul id="1" class="list-unstyled connectedLists">
<li class="panel panel-primary innerpanel" id="student_3_id">
<input type="hidden" name="student_3_id" value="1">
<div class="panel-body">
Student 3 Name
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-5" id="panel_2">
<div class="panel panel-default outerpanel">
<div class="panel-heading">
Group 2
</div>
<div class="panel-body">
<ul id="2" class="list-unstyled connectedLists">
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
The (functioning and simplified) Javascript code:
$(document).ready(function(){
jQuery(function(event, ui) {
$('.connectedLists').sortable({
connectWith: ".connectedLists",
stop: function(event, ui) {
item = ui.item;
var newList = item.closest("ul");
var group = newList.attr('id');
var formField = item.find("input");
formField.val(group);
},
});
});
};
Is there a way I can stop the sidebar from expanding when dragging? Thanks for looking through this mess!