Strugle alot but couldn't solve this problem. It been nightmare for me. I am using rails 6. and jquery ui "jquery-ui": "^1.13.0". I have added gem gem 'acts_as_list' and added yarn as yarn add jquery-ui.
I have added in application.js file
`require("jquery-ui/ui/widget")
require("jquery-ui/ui/widgets/sortable")`
and added the code
$(document).on("turbolinks:load", () => {
$("#employeeLevel").sortable({
handle: '.handle',
update: function(e, ui) {
Rails.ajax({
url: $(this).data("url"),
type: "PATCH",
data: $(this).sortable('serialize'),
success: function(result){
console.log('my msg'+result);
}
});
}
});
})
In index.html.slim addded an id as
tbody id="employeeLevel" data-url="<%= sort_employee_levels_path %>"
Waiting for your response. Thank you in advance
This is what I require for sortable:
You may need to expose jQuery in
config/webpack/environment.js: