Update by applying https://gist.github.com/chrismccord/2ab350f154235ad4a4d0f4de6decba7b JS hooks not working yet.
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
// We need to import the CSS so that webpack will load it.
|
|
// The MiniCssExtractPlugin is used to separate it out into
|
|
// its own CSS file.
|
|
import "../css/app.css"
|
|
|
|
// webpack automatically bundles all modules in your
|
|
// entry points. Those entry points can be configured
|
|
// in "webpack.config.js".
|
|
//
|
|
// Import deps with the dep name or local files with a relative path, for example:
|
|
//
|
|
// import {Socket} from "phoenix"
|
|
// import socket from "./socket"
|
|
//
|
|
import "phoenix_html"
|
|
import {Socket} from "phoenix"
|
|
import NProgress from "nprogress"
|
|
import {LiveSocket} from "phoenix_live_view"
|
|
|
|
import '@babel/polyfill'
|
|
import { copy_func } from './buttons'
|
|
|
|
let Hooks = {}
|
|
Hooks.SnippetInput = {
|
|
updated(){
|
|
this.el.value = this.el.dataset.updatedVal
|
|
copy_func()
|
|
console.log('yeah!')
|
|
}
|
|
}
|
|
|
|
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
|
|
let liveSocket = new LiveSocket("/live", Socket, {hooks: Hooks, params: {_csrf_token: csrfToken}})
|
|
|
|
// Show progress bar on live navigation and form submits
|
|
window.addEventListener("phx:page-loading-start", info => NProgress.start())
|
|
window.addEventListener("phx:page-loading-stop", info => NProgress.done())
|
|
|
|
// connect if there are any LiveViews on the page
|
|
liveSocket.connect()
|
|
|
|
// expose liveSocket on window for web console debug logs and latency simulation:
|
|
// >> liveSocket.enableDebug()
|
|
// >> liveSocket.enableLatencySim(1000)
|
|
window.liveSocket = liveSocket
|