Code Monkey home page Code Monkey logo

Comments (5)

jeffochoa avatar jeffochoa commented on July 21, 2024 3

Ok, I found a temporal solution. Using the custom turbo events, you can capture the submit-start to load the progress-bar manually as follows:

<script>
    document.addEventListener('turbo:submit-start', function () {
        Turbo.navigator.delegate.adapter.showProgressBar();
    });
</script>

from turbo.

todddickerson avatar todddickerson commented on July 21, 2024 1

@wnm try

import { Turbo } from "@hotwired/turbo-rails"
window.Turbo = Turbo // Turbo available throughout app

from turbo.

jeffochoa avatar jeffochoa commented on July 21, 2024

I'm having the same issue, it looks like you have to redirect AFTER handling the form-submission:

Turbo Drive handles form submissions in a manner similar to link clicks. The key difference is that form submissions can issue stateful requests using the HTTP POST method, while link clicks only ever issue stateless HTTP GET requests.

After a stateful request from a form submission, Turbo Drive expects the server to return an HTTP 303 redirect response, which it will then follow and use to navigate and update the page without reloading.

That doesn't work for me because I want to redirect the users to a different page, and that extra request is not ideal.

An option for me would be to disable Turbo on the actual form, but right now that's not possible, although there is an open PR for that #3

Hopefully that one will get merged soon 🤞

@coorasse please let me know if you find a workaround for this issue.

Cheers,
Jeff.

from turbo.

sudara avatar sudara commented on July 21, 2024

I posted on the Hotwire forums asking whether it should be default for the progress bar to always show on form submission. Otherwise, repeatedly rejected forms can appear as no-ops...

from turbo.

wnm avatar wnm commented on July 21, 2024

Ok, I found a temporal solution. Using the custom turbo events, you can capture the submit-start to load the progress-bar manually as follows:

<script>
    document.addEventListener('turbo:submit-start', function () {
        Turbo.navigator.delegate.adapter.showProgressBar();
    });
</script>

Is this still working for the latest version of Turbo? I'm loading Turbo via the hotwire-rails gem (and via the asset pipeline) and I get a Turbo is not defined error....

from turbo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.