Skip to content Skip to sidebar Skip to footer

Jquery Ui Sortable With Laravel Will Not Submit

After a lot of trial and error I finally got a sortable list to allow you to drag and drop to resort, but I cannot get the list to save. My guess is that it is an issue with the JS

Solution 1:

there's a few things wrong with your code I can see here - I'll try my best to set you on the right path:

Firstly in your view your li tag needs to have a data-order="" attribute containing the department id e.g.

<li data-id="{{ $department->id }}">{{ $department->name }}</li> 

This is so your JS can get and use this data at:

return $(this).data("id");

Secondly where your JS says:

data: {order: order, uuid: uuid},

You don't have a uuid so you don't need to submit one, you only need to submit the order like so:

data: {order: order},

And finally I would suggest you use the Google Chrome Javascript console to debug your javascript. It has good error reporting - just press Option+CMD+J on a Mac (I assume the Windows equivalent is Alt+Ctrl+J)

Post a Comment for "Jquery Ui Sortable With Laravel Will Not Submit"