动态 jquery ui 可排序块的索引/位置
Index/position of dynamic jquery ui sortable blocks?
不幸的是,我无法在jsfiddle中使用它,但也许我忽略了一些东西(http://jsfiddle.net/bJpyU/46/)。我动态创建了块,需要保存它们的下单。由于设置的动态方式,我无法获取索引(它始终为 0,并且无论拖动到何处,首先开始的块始终显示为第一个索引)。toArray 和序列化显示为空白。我什至尝试过数第n个孩子。知道如何获得订单吗?
.HTML
<div class="tab-pane active col-lg-12" id="portlet_tab_Graphs">
<div class="row padLR sortable_portlets" id="sortable_portlet_Graphs">
<div class="col-lg-4 sortable sortable_portlet_Graphs_column ui-sortable" id="102">
<div class="portlet box yellow">
<div class="portlet-title">Monthly License Revenue</div>
</div>
<div class="portlet-body clearfix pad">
<div id="h1_sortable_portlet_Graphs_102"></div>
<div id="sortable_portlet_Graphs_102">
<div class="col-lg-12 nPad">
<div class="btn-group chartToggle inline">Graph Data</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4 sortable sortable_portlet_Graphs_column ui-sortable" id="103">
<div class="portlet box blue">
<div class="portlet-title">Yearly License Revenue</div>
</div>
<div class="portlet-body clearfix pad">
<div id="h1_sortable_portlet_Graphs_102"></div>
<div id="sortable_portlet_Graphs_102">
<div class="col-lg-12 nPad">
<div class="btn-group chartToggle inline">Graph Data</div>
</div>
</div>
</div>
</div>
</div>
</div>
简讯
var sortdiv = "Graphs"
var blockClasses = "col-lg-4";
$(".sortable_portlet_" + sortdiv[2] + "_column").sortable({
connectWith: ".sortable_portlet_" + sortdiv[2] + "_column",
handle: ".portlet-title",
//placeholder: "dragColumn",
forceHelperSize: true,
forcePlaceholderSize: true,
start: function (e, ui) {
ui.placeholder.height(ui.helper.outerHeight());
ui.placeholder.width(ui.helper.outerWidth());
// get original block size
blockClasses = ui.item.parent().attr('class');
},
stop: function (e, ui) {
var parent = ui.item.parent();
blockWidth = blockClasses.split(" ");
parent.attr('class', function (i, c) {
return c.replace(/(^|'s)col-lg-'S+/g, blockWidth[0]);
});
//console.log(ui.position)
SavePortletDrop(sortdiv[2]);
}
});
我认为错误实际上是将sortable
附加到您正在排序的每个单独项目。它应该附加到容器div。
因此,即使它看起来有效,您实际上也在一堆 1 项列表中移动,这些列表始终位于索引 0 处。
我通过将sortable
附加到#sortable_portlet_Graphs
,让它像我认为您想要的那样工作.这使得ui.item.index()
返回您在stop
函数中期望的数字。
http://jsfiddle.net/bJpyU/47/
相关文章:
- 在从索引位置返回的字符串中查找空白
- 需要呈现MongoDB查询返回结果的特定索引/位置
- 有没有办法得到引导3旋转木马的索引位置
- 点击JQuery/HTML5显示元素的索引/位置
- Javascript i(index,iterator):如果用作变量,它将始终被解释为索引位置
- 获取所选元素的位置,而不是 DOM 中元素的索引
- Javascript 返回数组中“匹配”数组的位置索引
- 动态 jquery ui 可排序块的索引/位置
- Windows 8 应用程序中的索引数据库位置
- 如何删除字符串中的索引位置范围
- 工具提示 z 索引位置或其他内容
- jquery附加到索引位置
- 特殊字符的javascript验证's索引/位置
- Phonegap:在目录中导航,索引位置不正确
- 如何在AngularJS中保存对象的JSON索引位置,而不是对象本身
- 将数组元素按索引位置相乘
- 返回匿名函数数组的索引位置
- 哪个值是javascript数组.indexOf作为索引位置
- 如何通过文本搜索返回JSON数组中项目的索引位置?
- 按索引位置解析json对象数组