+
+tr.tDnD_whileDrag {
+ background: #ccc;
+ border: 2px solid black;
+}
+tr.tDnD_whileDrag :nth-child(4), tr.tDnD_whileDrag :nth-child(5) {
+ color: transparent;
+ background: transparent;
+}
+</style>
+<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
+<script src="js/jquery.tablednd.0.8.min.js"></script>
+<script text="text/javascript">
+ /** add table DnD as behavior **/
+ function onDragStart (table, row) {
+ console.log(table)
+ console.log(row)
+ }
+ function findRowPosition(table, row) {
+ }
+ function addInput(form, name, value) {
+ $(form).append('<input type="hidden" name="'+name+'" value="'+value+'">')
+ }
+ function addInputs(form, name, values) {
+ for(index = 0; index < values.length; index++) {
+ addInput(form, name+'['+index+']', values[index])
+ }
+ }
+ function onDrop(table, row) {
+ var row_ids = $.map(table.tBodies[0].rows, function(r) { return r.id} )
+ var row_id = row.id
+ var form = $(table).closest('form')[0]
+
+ addInput(form, 'row_id', row.id)
+ addInputs(form, 'row_order', row_ids )
+
+ JsHttpRequest.request(this, form);
+
+ }
+
+ var inserts = {
+ '#item_schedule table': function (e) {
+ $(e).tableDnD({onDragStart: onDragStart, onDrop: onDrop})
+ }
+ }
+Behaviour.register(inserts);
+</script>