Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using turbolinks progress bar for custom javascript requests ? #397

Closed
jpic opened this issue Jul 2, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@jpic
Copy link

commented Jul 2, 2018

Hello !

What's the best way to use the same progressbar as turbolinks for custom post requests ?

Thanks !

@packagethief

This comment has been minimized.

Copy link
Member

commented Jul 2, 2018

The API is pretty small: show(), hide(), and setValue(). The value should be a number between zero and one. Here's a quick example:

const progressBar = new Turbolinks.ProgressBar()

// Request started
progressBar.setValue(0)
progressBar.show()

// Request finished
progressBar.setValue(1)
progressBar.hide()

This will show the progress bar and start a synthetic trickle. If you're using XHR you can show actual progress by incrementing the value in response to the onprogress event. See Turbolinks.HttpRequest for an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.