Skip to content

Instantly share code, notes, and snippets.

@dwaynemac
Last active April 23, 2023 14:03
Show Gist options
  • Save dwaynemac/2d3ba6d77e7723877d7a33f3dc37af21 to your computer and use it in GitHub Desktop.
Save dwaynemac/2d3ba6d77e7723877d7a33f3dc37af21 to your computer and use it in GitHub Desktop.
hotwire stimulus and pulltorefresh.js
import { Controller } from "@hotwired/stimulus"
import PullToRefresh from "pulltorefreshjs"
/*
* Add data-controller="pull-to-refresh" to the element you want to be pulled on.
*/
export default class extends Controller {
connect() {
PullToRefresh.init({
mainElement: this.element,
onRefresh() {
Turbo.visit(window.location.href, { action: "replace" })
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment