News for hackers. Stuff that matters.
Re:How we got to LiveView by chrismccord on Wednesday September 22, 2021 @07:48PM (#28623514)
If you think the docs can be improved, please let us know. You can also find us on elixir-slack or elixirforum.com to ask for help. This should get you started:

    //<input type="text" name="body"  phx-hook="SubmitOnEnter"/>

    let Hooks = {}
    Hooks.SubmitOnEnter = {
      mounted(){
        this.el.addEventListener("keydown", e => {
          if(e.key === "Enter"){
            this.el.form.dispatchEvent(new Event("submit", {bubbles: true}))
          }
        })
      }
    }

    ...
    let liveSocket = new LiveSocket("/live", Socket, {hooks: Hooks, ...})

There are no comments on this comment yet.