Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sortable: Return an empty URL param for empty sortable lists. Fixed #…
…5794 - sortable("serialize", {key: "foo[]"}) returns an empty string for an empty list
- Loading branch information
9d01ab5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@holger Can you please sign our CLA?
9d01ab5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
9d01ab5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
9d01ab5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's been several years but I just stumbled upon this when trying to use custom "key" with serialize method.
What was the actual reason this change was made? I would add couple of counter arguments why this change shouldn't have been made and should maybe even be reversed.
There is now a difference in how ("serialize") and ("serialize", {key:"foo[]"}) work. There is no reason why those two should work differently. Either both should return "foo[]=" for empty lists or both should return empty string.
When submitting HTML form with un-checked checkboxes they also do not generate empty values and have to be handled on server side. Just as submitting empty sortable list should be handled on server side. https://api.jquery.com/serialize/ doesn't include un-checked checkboxes in the resulting string. This is another difference in the JQuery universe.
Most of the server side languages translate foo[]= as non empty array. Which is wrong considering that the sortable list was actually empty.
In case this is not going to be reversed, please update sortable documentation to reflect this anomaly and save the next person a lot of time trying to figure out what is going on.
@holger @scottgonzalez
9d01ab5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, any change is a breaking change for code written in the past seven years. However, this plugin is scheduled for a complete rewrite, at which point every part of the API will be reviewed.