585 search results for Turbo

{% block create %}
// ... lines 2 - 18
<turbo-stream action="append" target="product-{{ entity.product.id }}-toasts">
<template>
{{ include('_toast.html.twig', {
title: 'New Review!',
body: 'A new review was just posted for this product'
}) }}
</template>
</turbo-stream>
{% endblock %}
// ... lines 28 - 49
See Code Block in Script
// ... lines 1 - 2
import * as Turbo from '@hotwired/turbo';
export default class extends Controller {
// ... lines 6 - 8
connect() {
document.addEventListener('turbo:before-fetch-response', (event) => {
if (!this.modal || !this.modal._isShown) {
return;
}
const fetchResponse = event.detail.fetchResponse;
if (fetchResponse.succeeded && fetchResponse.redirected) {
event.preventDefault();
Turbo.visit(fetchResponse.location);
this.modal.hide();
}
});
}
// ... lines 23 - 27
}
See Code Block in Script
34 lines | templates/_modal.html.twig
<div
class="modal fade"
tabindex="-1"
aria-hidden="true"
data-modal-form-target="modal"
>
// ... lines 7 - 14
<turbo-frame
class="modal-body"
data-modal-form-target="modalBody"
data-action="submit->modal-form#submitForm"
src="{{ modalSrc }}"
>
{{ modalContent|default('Loading...') }}
</turbo-frame>
// ... lines 23 - 32
</div>
See Code Block in Script
32 lines | templates/cart/cart.html.twig
// ... lines 1 - 10
<aside class="col-12 col-md-4 order-2 order-md-1">
<turbo-frame id="cart-sidebar" src="{{ fragment_uri(controller('App\\Controller\\CartController::_cartFeaturedProduct')) }}" target="_top">
Loading...
</turbo-frame>
</aside>
// ... lines 17 - 32
See Code Block in Script
import { Controller } from 'stimulus';
import * as Turbo from '@hotwired/turbo';
export default class extends Controller {
count = 0;
static targets = ['count'];
increment() {
this.count++;
this.countTarget.innerText = this.count;
if (this.count === 10) {
Turbo.visit('/you-won');
}
}
}
See Code Block in Script
123 lines | src/Controller/VoyageController.php
// ... lines 1 - 13
use Symfony\UX\Turbo\TurboBundle;
// ... lines 15 - 16
class VoyageController extends AbstractController
{
// ... lines 19 - 27
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
// ... lines 30 - 33
if ($form->isSubmitted() && $form->isValid()) {
// ... lines 35 - 39
if ($request->headers->has('turbo-frame')) {
$request->setRequestFormat(TurboBundle::STREAM_FORMAT);
return $this->renderBlock('voyage/new.html.twig', 'stream_success', [
'voyage' => $voyage
]);
}
// ... lines 47 - 48
}
// ... lines 50 - 54
}
// ... lines 56 - 121
}
See Code Block in Script
97 lines | templates/base.html.twig
<!DOCTYPE html>
<html>
// ... lines 3 - 15
<body class="bg-black text-white font-mono">
// ... lines 17 - 51
<div
// ... lines 53 - 54
>
<dialog
// ... lines 57 - 59
>
<div class="flex grow p-5">
<div class="grow overflow-auto p-1">
<turbo-frame
// ... lines 64 - 67
>
{{ include('_frameSuccessStreams.html.twig', { frame: 'modal' }) }}
</turbo-frame>
</div>
</div>
</dialog>
// ... lines 74 - 89
</div>
// ... lines 91 - 94
</body>
</html>
See Code Block in Script
50 lines | templates/planet/show.html.twig
// ... lines 1 - 4
{% block body %}
<div class="m-4 p-4 bg-gray-800 rounded-lg">
// ... lines 7 - 8
<turbo-frame id="planet-info">
<table class="min-w-full bg-gray-800 text-white">
// ... lines 11 - 33
</table>
</turbo-frame>
// ... lines 36 - 47
</div>
{% endblock %}
See Code Block in Script
63 lines | templates/main/homepage.html.twig
// ... lines 1 - 4
{% block body %}
<div class="flex">
<aside class="hidden md:block md:w-64 bg-gray-900 px-2 py-6">
// ... line 8
<turbo-frame id="planet-info">
{{ include('main/_planet_list.html.twig') }}
</turbo-frame>
</aside>
// ... lines 13 - 60
</div>
{% endblock %}
See Code Block in Script
139 lines | templates/main/homepage.html.twig
// ... lines 1 - 27
{% block body %}
<div class="flex">
// ... lines 30 - 36
<section class="flex-1 ml-10">
// ... lines 38 - 56
<turbo-frame id="voyage-list" class="aria-busy:opacity-50 aria-busy:blur-sm transition-all">
// ... lines 58 - 134
</turbo-frame>
</section>
</div>
{% endblock %}
See Code Block in Script
<turbo-frame id="planet-card-{{ planet.id }}">
<div class="px-6 py-4">
<h4>
<a class="hover:text-blue-300 transition-colors duration-100" href="{{ path('app_planet_show', { id: planet.id }) }}">
{{ planet.name }}
</a>
</h4>
<small>{{ planet.lightYearsFromEarth|round|number_format }} ly</small>
</div>
</turbo-frame>
See Code Block in Script
First of all, thank you very much for the detailed response! Much appreciated! 1) On the controllers.json issue, I added the `mercure-turbo-stream` key (which was not there even though I ran recipes). So my file now ...
Hey Nick! I was just answering almost the same question for someone else this evening :). In short, while you can use Turbo Frames in some places (nice job getting this working btw!), you cannot use Turbo Drive with ...
weaverryan
weaverryan
Read Full Comment
Hey @Xavier-V! > Module build failed: Module not found: "../../vendor/symfony/ux-turbo/assets/dist/turbo_controller.js" contains a reference to the file "@hotwired/stimulus". This actually makes me think we have ...
weaverryan
weaverryan
Read Full Comment
Hello Ryan. I start using turbo now first for the frontend in our company. I did the first turbo page now and I have the first problem :). When I embed a controller with a (contact-)form (to be able to reuse it ...
Braunstetter
Braunstetter
Read Full Comment
Hi, I came across this comment while trying to reload a table with sorting and pagination after adding an entry. I installed Turbo 8 and experimented with the 'refresh' action along with the ``, and it works perfectly ...
Thanks for this great tutorial! Adding data-turbo-action="advance" makes the page jump back to the top of the page again when searching, clicking on the sorting or paging links. Removing it fixes that again. I thought ...
escobarcampos
escobarcampos
Read Full Comment
Hey Fabrice, In theory, it should be possible, you should just enable it for those pages in the way we show in our Turbo tutorial: https://symfonycasts.com/screencast/turbo . Though if you watched that course ...
... If the number of items per page is not divisible by 3 then I get a blank space in the grid when the next turbo frame is populated. I tried display:contents on the turbo-frames but that seems to prevent turbo from triggering the frame to load. I think maybe this is a downside. Is there a different way to do this?
Hi Ryan, - First point understood! thanks a lot. We understand that is not turbo responsability hiding and showing divs :) - Second point, sorry for my description, let me explain a bit better. Using turbo ...
SamuelVicent
SamuelVicent
Read Full Comment