I m, using jQuery 1.7 and jQuery UI 1.8 from Valle s CDN (so I have the recent edition).
我的网页上有两个内容,一个是头盔,另一个是装有每个头目清单项目的集装箱的内容区。 目前,我都附属于这两部,使我能够重新安排导航要素和内容集装箱的视线(另外)。 我试图实现的行为是,当我拖拉一个导航要素时,内容集装箱随之移动,而且当我把导航要素放在名单上的新位置时,内容集装箱也与其在内容领域的新立场保持一致。 我正在使用的网址是内联网网页,因此我无法提供链接,但我已经列入以下图表:
Navigation:
NavOne...NavTwo...NavThree
Content:
ContentOne...ContentTwo...ContentThree
After dragging NavThree between NavOne and NavTwo, the whole arrangement should look like this:
Navigation:
NavOne...NavThree...NavTwo
Content:
ContentOne...ContentThree...ContentTwo
是否有一种简单的方式将两个职业介绍所联系起来,以便他们以这种方式行事? 确实,有“ ” 能够顺利或“生存”(但我真的希望是这样)。 I m OK with it not reing the secondlyable list until the reordering in the first list is full (dropped).
我已经在“平等倡议”论坛上问过这个问题,等待一个星期的答复:
这里有一毫微米检测样本,然后转至实际项目:
<!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>
/* This is my CSS */
/* Basic reset -- outline for debugging */
* {padding: 0px; margin: 0px; outline: 1px solid rgba(0,0,0,0.1);}
html {width: 100%; height: 100%;}
body {width: 100%; height: 100%;}
/* Main styles */
.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>
<!-- This is my HTML -->
<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>
/* This is my JavaScript */
// Make containerDiv children sortable on X-axis
$(".containerDiv").sortable({
axis: "x"
});
// Make nav children sortable on x-axis
$(".navBar").sortable({
axis: "x",
items: "li"
});
// Bind sorting of each (.navBar li) to its corresponding (.containerDiv .itemDiv):
$(".navBar li").bind("mouseup", function(event,ui){
// If I use "sortupdate" I get little to no response. If I use "mouseup",
// I can at least get an alert to return the value of thisId.
// Note: I am sad that console.log is blocked in Firefox,
// because its DOM inspector is better than Chrome s
// the (.navBar li) have ids of "nav1, nav2" and so on,
// and the (.containerDiv .itemDiv) have corresponding ids of "item1, item2"
// which is my way of attempting to make it easier to link them.
// This line is my attempt to target the (.containerDiv .itemDiv) which directly
// corresponds to the (.navBar li) which is currently being sorted:
var tempId = "#" + $(this).attr( id ).replace("nav","item");
// When this (.navBar li) is updated after a sort drag,
// trigger the "sortupdate" event on the corresponding (.containerDiv .itemDiv):
$(tempId).trigger("sortupdate");
});
</script>
</html>
在那一周,我尝试了多种不同的可能解决办法,其中没有一个是我想要它们的工作。 我认为,这应当比较简单,但在一周内(在起飞和上)我有幸与它一道工作。
我已经阅读了以下相关内容,同时寻求一些见解:
- dragging multiple list items simultaneously
- JQuery Draggable + Sortable: How to tell if item was actually added to my sortable list?
- Sorting multiple items at the same time using jQuery UI
- jQuery UI Sortable: Multi-item select
- Is it possible to link two jquery.ui draggables together?
我认为,如果没有其他所有因素,我至少应该能够把可以分类的、向服务器发送的警示,然后根据序列化数据编制第二份更新清单,但我想继续把这一清单放在当地浏览器上,以减少对服务器的电话(直到用户选择将新的安排留给其账户)。
因此,StackOverflow...是我试图完成的一个合理/可完成的任务,还是我只是把我的头部推倒在这里的砖瓦? 我是否应当寻找不同的方式去做? 我愿尽可能避免改变Sortable plugin,但如果我必须,我将这样做。
我以前从未使用过jsFiddle,但我认识到,这或许会有所助益,因此:。