You're joining Squad # to the same columns
array. The code you had before produced the result it did because columns
is
- Squad 1
- Bob,Joe,John,Mark
- Squad 2
- Cletus,Ray ray,Billy Joe
- Squad 3
- Fred,Barney,Wilma
Which is why they were separated with pipes (|
).
To fix it as you want it, you'll want Squad # along with the other names. You can achieve this by changing both columns.push
lines to this one line:
columns.push( [$('#squad'+count).val()].concat($(this).sortable('toArray')).join(',') );
Effectively creating an array with the Squad # and concatenating the sorted ones at the end before joining them together with ,
.