-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
$nextTick doesnt work properly #333
Comments
It's currently an existing bug (I think). In the meantime, a possible workaround is to use a setTimeout (even a quick one like 100ms) instead of nextTick. |
@SimoTod I think it's probably worth investing time into this one then 🙂 |
@HugoDF I'm going to be busy with work tomorrow so I won't have time until the weekend. I'll let you know if I spot anything. |
@piotrpog I've tried your code pen and it seems to work okay for me. @HugoDF The issue on the other ticket seems to be related to transitions somehow. |
I came to the same conclusion when I ran into this the other day. |
@SimoTod By the way, using setTimeout workaround worked alright for me. |
Which browser are you using? |
oh yeah, you are right @piotrpog . I tried to add some console log and this is what happens:
So at the end, when all the 4 elements are now in the DOM, nextTick has already been emptied when only the previous images where in the dom. It seems an annoying bug to fix with the current implementation. |
Not the nicest code ever but something like https://github.com/alpinejs/alpine/compare/master...SimoTod:bug/nexttick?expand=1 |
I've updated the code, it now passes tests and it works with the other example too: https://codepen.io/SimoTod/pen/rNVggyO I had to duplicate part of the debounce function because I was under the impression that it was conflicting with the standard debouncing when I update a component but I might be wrong and we might be able to use the same function. Feedback welcome. |
facing the same issue when I use transition. Is it fixed in the 2.8.1 version? |
Here's codepen i created to illustrate the issue:
https://codepen.io/piotrpog/pen/dyoLwJO
I created list of images and initialized slider script swiper on it. So far so good. Then I swap these images and need re-initialize slider so it is displayed correctly.
I attached updating slider to button in codepen example. I used
$nextTick
, so slider updates only after now images are inserted. But id does not seems to work. I need to click button two times in order to make it work.The text was updated successfully, but these errors were encountered: