我必须构建一个应用程序,拖放功能似乎是最繁重的部分。根据以下一个或多个参数,Drag and Drop的最佳Ajax框架是什么:
答案 0 :(得分:6)
我的选择是jQuery UI。
答案 1 :(得分:1)
我最近做了类似的研究,并得出结论 JQuery 是要走的路。只是因为我找到了最多的可用和可理解的(对我而言)代码示例...其中一个我在这里发布(我忘了我剪切它的地方)。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; utf-8" />
<title>Sortables demo - Interface plugin for jQuery</title>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript" src="/interface/interface.js"></script>
<style type="text/css" media="all">
html
{
height: 100%;
}
img{
border: none;
}
body
{
background: #fff;
height: 100%;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
}
.groupWrapper
{
width: 32%;
float: left;
margin-right: 1%;
min-height: 400px;
}
.serializer
{
clear: both;
}
.groupItem
{
margin-bottom: 20px;
}
.groupItem .itemHeader
{
line-height: 28px;
background-color: #DAFF9F;
border-top: 2px solid #B5EF59;
color: #000;
padding: 0 10px;
cursor: move;
font-weight: bold;
font-size: 16px;
height: 28px;
position: relative;
}
.groupItem .itemHeader a
{
position: absolute;
right: 10px;
top: 0px;
font-weight: normal;
font-size: 11px;
text-decoration: none;
}
.sortHelper
{
border: 3px dashed #666;
width: auto !important;
}
.groupWrapper p
{
height: 1px;
overflow: hidden;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="sort1" class="groupWrapper">
<div id="newsFeeder" class="groupItem">
<div class="itemHeader">Feeds<a href="#" class="closeEl">[-]</a></div>
<div class="itemContent">
<ul>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
</ul>
</div>
</div>
<div id="news" class="groupItem">
<div class="itemHeader">News<a href="#" class="closeEl">[-]</a></div>
<div class="itemContent">
<ul>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
</ul>
</div>
</div>
<p> </p>
</div>
<div id="sort2" class="groupWrapper">
<div id="shop" class="groupItem">
<div class="itemHeader">Shopping<a href="#" class="closeEl">[-]</a></div>
<div class="itemContent">
<ul>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
</ul>
</div>
</div>
<p> </p>
</div>
<div id="sort3" class="groupWrapper">
<div id="links" class="groupItem">
<div class="itemHeader">Links<a href="#" class="closeEl">[-]</a></div>
<div class="itemContent">
<ul>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
</ul>
</div>
</div>
<div id="images" class="groupItem">
<div class="itemHeader">Images<a href="#" class="closeEl">[-]</a></div>
<div class="itemContent">
<ul>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
<li>orem ipsum dolor sit amet, consectetuer adipiscing elit</li>
</ul>
</div>
</div>
<p> </p>
</div>
<script type="text/javascript">
$(document).ready(
function () {
$('a.closeEl').bind('click', toggleContent);
$('div.groupWrapper').Sortable(
{
accept: 'groupItem',
helperclass: 'sortHelper',
activeclass : 'sortableactive',
hoverclass : 'sortablehover',
handle: 'div.itemHeader',
tolerance: 'pointer',
onChange : function(ser)
{
},
onStart : function()
{
$.iAutoscroller.start(this, document.getElementsByTagName('body'));
},
onStop : function()
{
$.iAutoscroller.stop();
}
}
);
}
);
var toggleContent = function(e)
{
var targetContent = $('div.itemContent', this.parentNode.parentNode);
if (targetContent.css('display') == 'none') {
targetContent.slideDown(300);
$(this).html('[-]');
} else {
targetContent.slideUp(300);
$(this).html('[+]');
}
return false;
};
function serialize(s)
{
serial = $.SortSerialize(s);
alert(serial.hash);
};
</script>
<div class="serializer">
<a href="#" onClick="serialize(); return false;" >serialize all lists</a>
<a href="#" onClick="serialize('sort1'); return false;" >serialize list 1</a>
<a href="#" onClick="serialize('sort2'); return false;" >serialize list 2</a>
<a href="#" onClick="serialize('sort3'); return false;" >serialize list 3</a>
<a href="#" onClick="serialize(['sort1', 'sort3']); return false;" >serialize lists 2 and 3</a>
</div>
<script language="JavaScript" type="text/javascript">var client_id = 1;</script>
<script language="JavaScript" src="http://stats.byspirit.ro/track.js" type="text/javascript"></script>
<noscript>
<p><img alt="" src="http://stats.byspirit.ro/image.php?client_id=1" width="1" height="1" /></p>
</noscript>
</body>
</html>
答案 2 :(得分:1)
我同意jQuery的所有人,但我想告诉你 script.aculo.us 作为替代方案。
1)学习曲线非常短暂
2)它有点沉重,因为你需要prototype.js(993kb)加上dragdrop.js(31kb)和scriptaculous.js(2kb)
3)完全支持IE6 +,Firefox(我说1.5 +,2 +肯定)和Safari(肯定2+,也许1.3 +)
答案 3 :(得分:0)
jQuery 目前似乎是市场领导者。它是轻量级的(19kb),并且有很多来自社区的插件。
(请注意 - 文件大小仅在缩小和GZipped时。添加UI会增加文件大小)
最常用的插件之一是与改进用户界面相关的插件,称为 UI ,并包含可拖动和可放置的功能。
jQuery UI的主页位于http://docs.jquery.com/UI
与“拖放”相关的其他插件列表位于http://plugins.jquery.com/project/Plugins/category/45