Last active
April 23, 2023 14:03
-
-
Save dwaynemac/2d3ba6d77e7723877d7a33f3dc37af21 to your computer and use it in GitHub Desktop.
hotwire stimulus and pulltorefresh.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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