You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a very weird problem right now.
I experimented with WebSockets and coded a Chat App using alpinejs.
I created a ChatApp function that is called via x-data="ChatApp()"
Inside this ChatApp() I'm returning an object that includes a init() method. (Code excerpt at the end)
The documentation states: "If the x-data object of a component contains an init() method, it will be called automatically."
I've build on that. Locally everything worked as expected.
But after I deployed the application it just didn't call the init() method inside the ChatApp() object. As a workaround I added a x-init="init()" and that worked on my production system too.
I just don't understand why there is a difference between the servers. I called it in the same browser and everything.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there,
I had a very weird problem right now.
I experimented with WebSockets and coded a Chat App using alpinejs.
I created a ChatApp function that is called via
x-data="ChatApp()"
Inside this ChatApp() I'm returning an object that includes a init() method. (Code excerpt at the end)
The documentation states: "If the x-data object of a component contains an init() method, it will be called automatically."
I've build on that. Locally everything worked as expected.
But after I deployed the application it just didn't call the init() method inside the ChatApp() object. As a workaround I added a
x-init="init()"
and that worked on my production system too.I just don't understand why there is a difference between the servers. I called it in the same browser and everything.
JS looks something like this:
I'm using Laravel Echo here... But a simple js alert() won't get called either.
In my HTML I have an object root for my alpine object:
Doesn't work on production, but on localhost
Does work on production and on localhost.
I'm just trying to understand why there is a difference between both servers. Maybe someone has an idea.
Beta Was this translation helpful? Give feedback.
All reactions