$tf
A turbo-frame helper.
$tf is a handle for the nearest <turbo-frame> around the scope. The name is short for turbo-frame. Use it when a button inside a frame reloads its own frame or moves it to another URL.
This example runs without Turbo, so only the URL changes. If Turbo is loaded, the frame loads the new content the moment you call visit().
| Name | What it does |
|---|---|
$tf.el | The nearest <turbo-frame> around the scope. null if there is none |
$tf.reload() | Reloads the frame from its current URL |
$tf.visit(url) | Moves the frame to another URL. Reloads if it is the same as the current URL |
Calling reload() or visit() outside a frame does not throw. It only logs a warning to the console. Called inside h-state or h-for, it still sees that scope's frame.
Adding it
With a plain script tag, load extensions/turbo-frame.iife.js.