function dragMode() { $('#card-list').sortable({ placeholder: "highlight", update: function( event, ui ) { var _userPosition = {}; _userPosition.position = $(ui.item).index(); _userPosition.id = $(ui.item).data('user-id'); $.ajax({ url: "<%= Rails.application.routes.url_helpers.update_order_card_admin_users_new_interface_index_path %>", type: 'POST', dataType: 'script', data: {users: _userPosition} }); } }); $('#card-list').disableSelection(); } function typeMode() { var _userPosition = []; $('#list-view tbody tr').each(function(i) { $(this).data('user-index', i); }); $('#member-list').on(clickEvent, '.edit_position', function(e){ var $input = $(''), $cross = $(''); if($(this).siblings('input').length) { $(this).siblings('input').attr('type', 'text').after($cross); } else { $(this).after($cross); $(this).after($input); } $(this).hide(); $input.val($(this).text()); e.preventDefault(); $cross.click(function(event) { $input.remove(); $(this).siblings('a').show().end().remove(); }); }); $('.bottomnav').on(clickEvent, '.btn', function(e) { _userPosition = []; $('#member-list tbody input').each(function(i) { _userPosition.push([$(this).val(), $(this).siblings('a').data('user-id')]); }); $.ajax({ url: "<%= Rails.application.routes.url_helpers.update_order_list_admin_users_new_interface_index_path %>", type: 'POST', dataType: 'script', data: {users: _userPosition} }); e.preventDefault(); }); };