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

CartJS does not remove the right element #28

Closed
bakura10 opened this issue Jun 30, 2015 · 3 comments
Closed

CartJS does not remove the right element #28

bakura10 opened this issue Jun 30, 2015 · 3 comments

Comments

@bakura10
Copy link
Contributor

Hi again,

Sorry for pinging you again. I'm still trying to integrate animation. So here is my try: when clicking on the element, I first toggle the element using jQuery, then I remove the item using CartJS:

removeProduct: function(event) {
      var element = $(event.currentTarget),
          item = element.closest('.mini-cart__item'),
          variantToRemove = item.attr('data-variant');

      item.toggle(150, function() {
        CartJS.updateItemById(variantToRemove, 0);
      });

      return false;
    }

What happen is the following:

jQuery performs its animation, and set the element as display: none. Then, CartJS remove the element. But it seems that because the lement is hidden, binding does not work correctly, and instead of removing the first one that was hidden, it actually removes the first one and then... add all the classes that was on the first element (display: none), and apply it to the second element (hence making it invisisible).

I'm not sure if this is clear, but the simplest is to try it to understand the issue :).

@gavinballard
Copy link
Member

@bakura10: Did you ever work out the cause of this issue, or learn anything more about it? Trying to do an issue spring clean :).

@bakura10
Copy link
Contributor Author

I'll check again but I think I did a funny hack with setTimeout and something like that. I'll have a closer look ;).

@gavinballard
Copy link
Member

Closing due to inactivity. Happy to investigate similar issues if presented with reproduction steps.

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

2 participants