Last active
February 27, 2016 08:10
-
-
Save matthiask/c72800606d0765225812 to your computer and use it in GitHub Desktop.
admin list sortable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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