Skip to content
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

Reset "newIndex" value when dragging element between lists. #488

Closed
timbergus opened this issue Jul 22, 2015 · 5 comments
Closed

Reset "newIndex" value when dragging element between lists. #488

timbergus opened this issue Jul 22, 2015 · 5 comments
Labels

Comments

@timbergus
Copy link

I'm not sure if there is another way to do this, but my problem is the following:

I have two lists A and B, and I want to drag an element from list A to list B. First time I drag inside list B an element from list A, the newIndex value is set to the position value where I have dropped the list A element on list B, but, if then I drag a new element from list A but I drop it outside list B, the newIndex value is not set again to undefined. Instead, it keeps the value of the last successful drop inside list B. Is there any way to set newIndex to undefined everytime I start a new drag from list A?

What I need is to know if I drop the element from list A inside list B or everywhere else inside the page to warn the user with an alert to drop the element in the right place.

Example in CodePen

Try to drag an element from green list to white space between lists. Then try again but now from green list to blue list, and again from green list to white space. The newIndex value remains instead of being undefined.

RubaXa added a commit that referenced this issue Jul 28, 2015
@RubaXa RubaXa added the bug label Jul 28, 2015
@RubaXa
Copy link
Collaborator

RubaXa commented Jul 28, 2015

Fixed: http://codepen.io/anon/pen/QbJyER
Try dev-branch.

@timbergus
Copy link
Author

The pen works great. Thanks. But in my code sometimes I'm having the following error:

Uncaught TypeError: Cannot read property 'Sortable1438080226654' of null in Sortable.js:1031

It happens randomly when I drag the new element at the end of the list, but it happens mostly when I drag new element in between. Maybe is a bug in my code. I will try to double check it.

Thanks again for you help :)

RubaXa added a commit that referenced this issue Jul 30, 2015
@RubaXa
Copy link
Collaborator

RubaXa commented Jul 30, 2015

Fixed. Try again dev-branch.

@timbergus
Copy link
Author

Working like a charm! And I'm sure you already know this, but just in case, I have this non related error:

Uncaught ReferenceError: ko is not defined in knockout-sortable.js:136

Thanks a lot for your help :)

@RubaXa
Copy link
Collaborator

RubaXa commented Jul 31, 2015

@srosengren ⬆️ ⬆️ ⬆️ ?

srosengren added a commit to srosengren/Sortable that referenced this issue Jul 31, 2015
RubaXa added a commit that referenced this issue Jul 31, 2015
@RubaXa RubaXa closed this as completed Sep 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants