…downloading the source code of the widget and trying to make sense of it) is that it does something on window.load event. And since this event is not fired on turbo visits the widget is not initialised properly.
This is an excellent theory. Unfortunately…
…page again... but adding the defer attribute to it. Check a few screencasts to learn more about it:
- https://symfonycasts.com/screencast/stimulus/encore
- https://symfonycasts.com/screencast/turbo/disabling
As you can see, Webpack Encore already knows how to handle it, you just need…
…Turbo will follow it. I feel I'm missing some important detail here (because that answer is too simple) - so please let me know :).
> and another just show a pre-loaded content that was previously hidden
Turbo won't help you here - this is…
…We though about creating a controller which first link loads content via Turbo.visit('url') (needed to import the turbo library) and the other just shows a hidden static content (we find this approach a bit cumbersome).
- Is there any way to load dynamic content…
…and action for the user to take. As I'm reading this wouldn't trigger a rerendering of the HTML and testing proves that's true. Is there an elegant solution to this or would disabling turbo/hotwire on the form be the better approach?
|
<?php |
|
|
|
return [ |
|
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], |
|
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], |
|
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], |
|
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], |
|
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], |
|
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], |
|
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], |
|
Symfony\UX\Turbo\TurboBundle::class => ['all' => true], |
|
]; |
See Code Block in Script
|
<?php |
|
|
|
return [ |
|
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], |
|
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], |
|
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], |
|
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], |
|
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], |
|
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], |
|
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], |
|
Symfony\UX\Turbo\TurboBundle::class => ['all' => true], |
|
Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true], |
|
]; |
See Code Block in Script
…interesting, this error is only triggered on debug mode, with the Symfony profiler. I put the environment in production mode and Turbo works like a charm!
Let me know if you have some idea why is loading twice on dev mode with the profiler!
Thanks…
…Is there really a Mercury tutorial planned? That would be great ! If yes, for when could we have access to it?
Do you plan to do a Mercury training again combining it with Turbo, or this time, with a traditional Symfony project not using Turbo?
Hi David!
The JavaScript ecosystem has indeed grown and matured A LOT during the past 6 or so years. It's quite remarkable! I'm glad you find this useful! I think you will love the stimulus/turbo tutorials as well!
…in the template for a page, you embed a controller (`render(controller())` correct?) that renders a contact form.
Question: (ignoring Turbo for a moment - just pretend you're on a non-Turbo site), where does that contact for submit to? Does it submit to a…
…looks pretty similar to the core Mercure + Turbo code (it's not exactly the same use-case, but the EventSource stuff is the same - https://github.com/symfony/ux/blob/main/src/Turbo/Bridge/Mercure/Resources/assets/src/turbo_stream_controller.js )
Sorry I can…
…I hate", when you're scrolling a page and things are lazily loaded and it makes the page "jump" because it takes a while for that content to load. What if you had a 'load-this-FUTURE-content' trigger (maybe an empty turbo element??) that…
…generally-speaking, we do something pretty similar on this tutorial. You could put a turbo-frame around the entire "comments" area... which has the advantage that only that area updates when a new comment is added. But I'm guessing there is more to your…
…feel that same way - along with Turbo. It's completely changed the JavaScript paradigm for me, and allowed me to get that single-page-app experience with a "normal" app. We've been prepping the SymfonyCasts codebase for Turbo (mostly be refactoring legacy JavaScript into…
…and Turbo, the entire universe seems to be shaken. I would definitely say that Stimulus + Turbo is the future of front-end, at least for Symfony projects, because this seems to be *just* what Symfony needs! (Go take a look at our Stimulus and Turbo…
…redirecToRoute() to return a redirect response, but you're adding a `#something` to the end of it (is that what you mean by "anchor")? Or were you referring to Symfony's fragments system - https://symfonycasts.com/screencast/turbo/frames-find-frames#using-fragment-uri ?
Cheers!
…This IS what I would do, however, in 99% of the cases when I needed to do a manual visit in Turbo. But you mentioned:
> The routes are created using data from an ajax response
Ok, so you basically have a situation where you…
…then Turbo wouldn't be active and each "click" on your site would be a normal full page refresh, and so that would work perfectly too. And third, in case it helps you be more confident, Turbo (as Turbolinks) has been around for *years* and…
…at the moment :). However, we cover the mechanics of Mercure pretty well in this tutorial. The biggest difference would be that you would want to publish some JSON information to Mercure instead of turbo-stream HTML. Then, in JavaScript/React, you would read this JSON…
x
682