I am using jQuery 1.7 and jQuery UI 1.8 from Google CDN (so I have the latest versions).
I have two elements on my page: a header and a content area with containers that correspond to each element in the header list. I currently have Sortable attached to both, allowing me to change the order of visibility of both the navigation items and the content containers (separately). The behavior I'm trying to achieve is that when I drag a navigation item, the content container moves with it, and when I delete the navigation item at a new position in the list, the content container snaps to its new position in the content area. The website I am working on is an intranet page, so I cannot provide a link, but I have included the following scheme:
Navigation:
NavOne...NavTwo...NavThree
Content:
ContentOne...ContentTwo...ContentThree
After dragging NavThree between NavOne and NavTwo, the whole layout should look like this:
Navigation:
NavOne...NavThree...NavTwo
Content:
ContentOne...ContentThree...ContentTwo
, ? , "" ( , ). , , ().
jQuery UI : [LINK]
, , :
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<style>
* {padding: 0px; margin: 0px; outline: 1px solid rgba(0,0,0,0.1);}
html {width: 100%; height: 100%;}
body {width: 100%; height: 100%;}
.containerDiv {
overflow-x: scroll;
overflow-y: hidden;
width: 800px;
height: 600px;
white-space: nowrap;
float: left;
}
.itemDiv {
width: 200px;
height: 500px;
display: inline-block;
}
.navBar ul, .navBar li {
display: inline;
}
</style>
</head>
<body>
<div class="navBar">
<ul>
<li id="nav1">Navigation 1</li>
<li id="nav2">Navigation 2</li>
<li id="nav3">Navigation 3</li>
</ul>
</div>
<div class="containerDiv">
<div class="itemDiv" id="item1">Item 1</div>
<div class="itemDiv" id="item2">Item 2</div>
<div class="itemDiv" id="item3">Item 3</div>
</div>
</body>
<script>
$(".containerDiv").sortable({
axis: "x"
});
$(".navBar").sortable({
axis: "x",
items: "li"
});
$(".navBar li").bind("mouseup", function(event,ui){
var tempId = "#" + $(this).attr('id').replace("nav","item");
$(tempId).trigger("sortupdate");
});
</script>
</html>
, , . , , ( ) .
, :
, , , , ajax , , , ( ).
, StackOverflow... / , , ? ? Sortable, , , .
jsFiddle, , , , , : http://jsfiddle.net/34u7n/1/