diff --git a/.gitignore b/.gitignore index d9437c3..b4a6fab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ *.log *.pot *.pyc diff --git a/orderable/templates/admin/orderable_change_list.html b/orderable/templates/admin/orderable_change_list.html index f7e4b31..47e9f75 100644 --- a/orderable/templates/admin/orderable_change_list.html +++ b/orderable/templates/admin/orderable_change_list.html @@ -7,6 +7,11 @@ { cursor: pointer; } + + /*Fix for grappelli*/ + .ui-sortable { + float: inherit !important; + } {% endblock %} @@ -20,9 +25,13 @@ // Only add the drag-n-drop reordering if this is not a paginated object (determined by the presense of a span, which isn't the best way to do it…) if ($("p.paginator > span")) { + // Check grappelli prefix + var grappelli_prefix = window.grappelli === undefined ? "" : "grp-"; + + var table_select = $("#" + grappelli_prefix + "changelist table tbody"); // Steal the draghandle's id and apply to the row - $("#changelist table tbody tr").each(function() { + table_select.find("tr").each(function() { var id = $(".sorthandle", this).attr("id"); $(this).attr("id", id); $(".sorthandle", this).attr("id", ""); @@ -34,12 +43,12 @@ $(".sorthandle").html("Drag to reorder"); // Force a width onto all the tds (so they drag nicely) - $("#changelist table tbody tr > *").each(function() { + table_select.find("tr > *").each(function() { $(this).width($(this).width()) }); // Do the draggable - $("#changelist table tbody").sortable({ + table_select.sortable({ 'axis': 'y', // 'containment': 'parent', 'cursor': 'crosshair', @@ -51,7 +60,7 @@ cereal += '&csrfmiddlewaretoken=' + $("input[name=csrfmiddlewaretoken]").val(); var classflip = 1; - $("#changelist table tbody tr").each(function() { + table_select.find("tr").each(function() { // redraw the tabel striping $(this).removeClass("row1 row2"); if (classflip) { @@ -68,11 +77,7 @@ $.ajax({ url: "reorder/", type: "POST", - data: cereal/*, - success: function(feedback) { - console.log(feedback); - // $('data').html(feedback); - }*/ + data: cereal }); }