|
@@ -310,31 +310,34 @@
|
|
|
<script>
|
|
|
$(document).ready(function() {
|
|
|
$(function() {
|
|
|
- $("#sortable-section-templates").sortable({
|
|
|
- stop: function(event, ui) {
|
|
|
- var sectionTemplates = [];
|
|
|
- $('#sortable-section-templates').children('tr').each(function(index, element) {
|
|
|
- var sectionTemplateInternalName = $(element).attr('data-internal-name');
|
|
|
- console.log(index, sectionTemplateInternalName);
|
|
|
- sectionTemplates.push({
|
|
|
- positionIndex: index,
|
|
|
- internalName: sectionTemplateInternalName
|
|
|
+ $('.sortable').each(function(index, el) {
|
|
|
+ var url = $(el).attr('data-url');
|
|
|
+ $(el).sortable({
|
|
|
+ stop: function(event, ui) {
|
|
|
+ var data = [];
|
|
|
+ $(el).children('tr').each(function(index, element) {
|
|
|
+ var uid = $(element).attr('data-uid');
|
|
|
+ data.push({
|
|
|
+ positionIndex: index,
|
|
|
+ uid: uid
|
|
|
+ });
|
|
|
+ })
|
|
|
+ console.log(data);
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: url,
|
|
|
+ data: JSON.stringify(data),
|
|
|
+ contentType: 'application/json',
|
|
|
+ success: function(response) {
|
|
|
+ console.log(response);
|
|
|
+ },
|
|
|
+ dataType: 'json'
|
|
|
});
|
|
|
- })
|
|
|
- console.log(sectionTemplates);
|
|
|
- $.ajax({
|
|
|
- type: "POST",
|
|
|
- url: '/api/sectionTemplate/sort',
|
|
|
- data: JSON.stringify(sectionTemplates),
|
|
|
- contentType: 'application/json',
|
|
|
- success: function(response){
|
|
|
- console.log(response);
|
|
|
- },
|
|
|
- dataType: 'json'
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- $("#sortable-section-templates").disableSelection();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $(el).disableSelection();
|
|
|
+ })
|
|
|
+
|
|
|
});
|
|
|
})
|
|
|
</script>
|