2
我有多個UL中,我可以在它們之間拖放li元素:保存多個JQuery的可排序在同一個表
<div class="outer-box">
<div class="header text-center">
<h4 class="title">Curriculum</h4>
<p class="category">Start putting together your course by creating sections, lectures and practice quizzes below.</p>
</div>
<div class="inner-box">
<div class="header">
<h4 class="title text-left">Section 1:</h4>
<div class=" header text-left">
<ul class="sortable ui-sortable" style="list-style-type: none;">
<li class="lecture ui-sortable-handle">
<p><small><span class="glyphicon glyphicon-ok" aria-hidden="true" style="color: #17AA1C;"></span> Lecture 3: Testing</small></p>
</li><li class="lecture ui-sortable-handle">
<p><small><span class="glyphicon glyphicon-ok" aria-hidden="true" style="color: #17AA1C;"></span> Lecture 1: Testing</small></p>
</li><li class="lecture ui-sortable-handle">
<p><small><span class="glyphicon glyphicon-ok" aria-hidden="true" style="color: #17AA1C;"></span> Lecture 2: Testing</small></p>
</li>
</ul>
</div>
</div>
</div>
<div class="inner-box">
<div class="header">
<h4 class="title text-left">Section 2:</h4>
<div class=" header text-left">
<ul class="sortable ui-sortable" style="list-style-type: none;">
<li class="lecture ui-sortable-handle">
<p><small><span class="glyphicon glyphicon-ok" aria-hidden="true" style="color: #17AA1C;"></span> Lecture 5: fasd</small></p>
</li>
</ul>
</div>
</div>
</div>
<div class="inner-box">
<div class="header">
<h4 class="title text-left">Section 3:</h4>
<div class=" header text-left">
<ul class="sortable ui-sortable" style="list-style-type: none;">
<li class="lecture ui-sortable-handle">
<p><small><span class="glyphicon glyphicon-ok" aria-hidden="true" style="color: #17AA1C;"></span> Lecture 4: asdf</small></p>
</li>
</ul>
和文字是讓它拖多個UL之間是下降
<script type="text/javascript">
$('.sortable').sortable({
connectWith: '.sortable',
revert: true
});
</script>
基本上我試圖在數據庫中保存它所具有的部分編號和講座編號。
例如:
section_id | lecture_id |
1 3
1 1
1 2
2 5
3 4
,這樣,當我加載它加載在它保存的順序。
我不能應用ajax來保存這種結構。
謝謝。
什麼是不工作,或者你嘗試過什麼? Sortable有幾個方法來收集這些細節:'serialize'和'toArray',並且可以通過AJAX傳遞給你的腳本進行保存。 – Twisty