Closed sabat24 closed 1 year ago
It seems good to me. Maybe something cache related? How did you run webpack? When you use watch is usually needs a restart to notice new packages.
Does your webpack.config.js
contain:
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge('./assets/controllers.json')
You should try to remove the app.register('live', LiveController);
and restart the watcher or rebuild the app.
Does your webpack.config.js contain:
Yes. It was turned on and it worked I guess, because I was able to correctly run assets/controllers/hello_controller.js
How did you run webpack?
The first few times I used the yarn build
command (which creates a production build). Later I changed the command to yarn dev
to create development build. I have never used a watcher.
I'll try to prepare a demo app and deploy it somewhere to confirm my settings.
Yea, everything looks good to me too. You literally showed all the code from your app that should be enough to get this working. Very strange.
@1ed @weaverryan I was able to reproduce the issue on my demo app.
package.json
)https://live-demo.sabat24.pl/live - simple live component with page
liveProp and updatePage
liveAction. It's a basic bootstrap file without any modifications. After clicking a text, live action should be triggered and page
should change from 1
to 2
. I tested on FF - nothing happened.
To prove that Stimulus workscorrectly you can test it on https://live-demo.sabat24.pl/hello
https://live-demo.sabat24.pl/live2 - same component but I created another entry point for webpack with my modifications (import and registration of live_controller
manually). This version works fine.
@sabat24 please run yarn upgrade
or just yarn add @symfony/stimulus-bridge@^3.2.0
, because you are using an old version, which doesn't contain https://github.com/symfony/stimulus-bridge/pull/70. But I don't know how you got that, because when I create a new project I get 3.2.1?
Thanks for that information. This actually solved my problem.
I added stimulus-bridge
to my repository on April. The demo repository wasn't created from the scratch. I included my original .lock
files to get same dependencies versions in both repositories.
symfony/webpack-encore-bundle:^1.14
.symfony/ux-live-component:^2.6
and ranyarn install
controllers.json
was created, I importedbootstrap.js
and so on.data-controller="live"
attribute. However there were no ajax actions triggered bylive#$render
orlive#$action
.My
controllers.json
fileI had to manually import
'@symfony/ux-live-component
in mybootstrap.js
and then register it as a controller.Then it started to work fine. I guess that it shouldn't behave like that, because that package should be registered by
startStimulusApp
.Did I do something wrong? Why did I have to register that controller manually?