Skip to content

Using jquery's $.map flattens array arguments in the callbacks #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mtraynham opened this issue Jan 5, 2015 · 1 comment
Closed

Using jquery's $.map flattens array arguments in the callbacks #146

mtraynham opened this issue Jan 5, 2015 · 1 comment

Comments

@mtraynham
Copy link

Encountered during the upgrade to 1.0.9, likely caused by #102

If you have a onDrop callback that has an array argument, jquery's map function will flatten that array.

For instance:

$.map([1, 2, 3], function(element, index) {
  return [ element + 1, element + 2 ];
});
=> [2, 3, 3, 4, 4, 5]

I pass the drop target array reference as an argument in the onDrop callback. Workaround is wrapping that array reference with an array as shown from: http://stackoverflow.com/questions/703355/is-there-a-jquery-map-utility-that-doesnt-automically-flatten:

$.map([1, 2, 3], function(element, index) {
  return [ [ element + 1, element + 2 ] ];
});
=> [[2, 3], [3, 4], [4, 5]]
@mtraynham
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant