Skip to content

Instantly share code, notes, and snippets.

@matthiask
Last active February 27, 2016 08:10
Show Gist options
  • Save matthiask/c72800606d0765225812 to your computer and use it in GitHub Desktop.
Save matthiask/c72800606d0765225812 to your computer and use it in GitHub Desktop.
admin list sortable
<script type="text/javascript" src="/static/app/jquery-ui-1.11.4.custom.min.js"></script>
<style>#result_list tbody tr { cursor: move; }</style>
<script>
django.jQuery(function($) {
$('#result_list tbody').sortable({
update: function(event, ui) {
$('#result_list tbody tr').each(function(index) {
var row = $(this);
row.find('.field-ordering input').val(10 * (index + 1));
row.removeClass('row1 row2').addClass((index % 2) ? 'row2' : 'row1');
});
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment