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

Permanent Alpine.js element throws error: Uncaught (in promise) TypeError: i is not a function #108

Closed
alexmandrikdev opened this issue May 9, 2023 · 7 comments
Assignees

Comments

@alexmandrikdev
Copy link

Hey guys!

When I make the navigation bar permanent that contains Alpine.js, the app throws this error when I visit a page via Turbo Drive.

image

I'm getting this error from a fresh Laravel Breeze + Turbo Laravel installation (I've followed the installation guide).

The alpine-turbo-drive-adapter solves this problem, but it causes issues with the Livewire @entangle directive.

Do you have any ideas on how to fix this problem?

@tonysm tonysm self-assigned this May 9, 2023
@tonysm
Copy link
Collaborator

tonysm commented May 9, 2023

@alexmandrikdev Hey, thanks for reporting. Do you have this snippet in the Alpine.js setup?

I'm gonna try to reproduce it here.

@alexmandrikdev
Copy link
Author

alexmandrikdev commented May 10, 2023

@alexmandrikdev Hey, thanks for reporting. Do you have this snippet in the Alpine.js setup?

I'm gonna try to reproduce it here.

Yes, It was added by the php artisan turbo:install --alpine command just before the Alpine.js initialization.

image

@tonysm
Copy link
Collaborator

tonysm commented May 10, 2023

@alexmandrikdev can you move the alpine setup to the libs/alpine.js file? And make sure you place it before line 14 there. Let me know if that changes anything.

@alexmandrikdev
Copy link
Author

@alexmandrikdev can you move the alpine setup to the libs/alpine.js file? And make sure you place it before line 14 there. Let me know if that changes anything.

I've already tried this, but it hasn't solved the problem.

image

This might be helpful. Every time I navigate to a different page, the event listener is added to the button repeatedly.

image

By the way, why does the turbo:install command put the initAlpineTurboPermanentFix function call before the Alpine initialization? Is this on purpose?

@alexmandrikdev
Copy link
Author

I've published the app on GitHub: https://github.com/alexmandrikdev/laravel-turbo-integration-test.

@tonysm
Copy link
Collaborator

tonysm commented May 12, 2023

@alexmandrikdev

By the way, why does the turbo:install command put the initAlpineTurboPermanentFix function call before the Alpine initialization? Is this on purpose?

I think that's actually a bug in the installer command. I'm gonna take a look at it.

@tonysm
Copy link
Collaborator

tonysm commented Oct 24, 2023

Hey, I'm gonna close this. Not sure if it's still an issue for you. I have another issue to test with Livewire 3 here.

@tonysm tonysm closed this as completed Oct 24, 2023
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