불행히도 jsfiddle에서이 작업을 수행하지 못했지만 어쩌면 뭔가 (간추린 내용) (http://jsfiddle.net/bJpyU/46/)가 있습니다. 동적으로 생성 된 블록이 있고 배치 된 순서를 저장해야합니다. 역동적 인 방식으로 설정되었으므로 인덱스를 가져올 수 없습니다 (항상 0이고 블록 시작은 항상 끌어온 위치에 관계없이 첫 번째 인덱스로 표시됩니다). toArray 및 serialize가 비어있는 것으로 표시됩니다. 나는 심지어 제 n 자녀를 세어 보았습니다. 순서를 얻는 방법 어떤 아이디어?동적 jquery와 정렬 가능한 블록의 색인/위치?
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>
JQUERY
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]);
}
});
초기 관찰 : 다음이'sortdiv = 'Graphs''하지만'sortdiv [2]'. sortdiv가 배열인가, 아니면'[2]'가 에러입니까? – evanbikes