当拖动门户离开列时,我期待“sortout”事件触发。“sortover”事件按预期触发。我不确定这是它应该工作的方式还是 jquery UI 被破坏。
这是演示代码http://jsfiddle.net/kY7SV/6/ 将所有 portlet 拖出列,它应该会折叠。将 portlet 拖到折叠的列上,它应该会展开。
帮助表示赞赏
为 Merlyn 编辑重要的部分:
<ul id="sm" class="sm">
<li id=list1><div style="background-color:red">1</div>
<div class="column" id='col1'>
<div class="portlet">
<div class="portlet-header">Feeds</div>
<div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
</div>
<div class="portlet">
<div class="portlet-header">News</div>
<div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
</div>
</div>
</li>
<li id=list2><div style="background-color:yellow">2</div>
<div class="column" id='col2'>
<div class="portlet">
<div class="portlet-header">Shopping</div>
<div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
</div>
<div class="portlet">
<div class="portlet-header">Messages</div>
<div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
</div>
</div>
</li>
<li id=list3><div style="background-color:blue">3</div>
<div class="column" id='col3'>
<div class="portlet">
<div class="portlet-header">Links</div>
<div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
</div>
<div class="portlet">
<div class="portlet-header">iMAGES</div>
<div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
</div>
</div>
</li>
</ul>
$(function() {
$(".column").sortable({
connectWith: ".column"
});
$(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all").find(".portlet-header").addClass("ui-widget-header ui-corner-all").prepend("<span class='ui-icon ui-icon-minusthick'></span>").end().find(".portlet-content");
$(".portlet-header .ui-icon").click(function() {
$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
$(this).parents(".portlet:first").find(".portlet-content").toggle();
});
$(".column").disableSelection();
$(".column").bind("sortremove", function(event, ui) {
var listitem = $(this).parents('li');
var cnt = $(this).children().length;
if (cnt < 1) {
$(listitem).css('maxWidth', '25px');
}
});
$(".column").bind("sortover", function(event, ui) {
var listitem = $(this).parents('li');
$(listitem).css('maxWidth', '');
});
$(".column").bind("sortout", function(event, ui) {
var listitem = $(this).parents('li');
var cnt = $(this).children().length;
if (cnt < 1) {
$(listitem).css('maxWidth', '25px');
}
});
$(".column").bind("sortreceive", function(event, ui) {
var listitem = $(this).parents('li');
$(listitem).css('maxWidth', '');
});
});