Current section
Files
Jump to
Current section
Files
priv/static/live_select.min.js
export default{LiveSelect:{attachDomEventHandlers(){this.el.querySelector("input[type=text]").onkeydown=e=>{e.code=="Enter"&&e.preventDefault(),this.pushEventTo(this.el,"keydown",{key:e.code})},this.el.querySelector("ul").onmouseover=()=>{this.pushEventTo(this.el,"dropdown-mouseover",{})},this.el.querySelector("ul").onmouseleave=()=>{this.pushEventTo(this.el,"dropdown-mouseleave",{})}},setSearchInputValue(e){this.el.querySelector("input[type=text]").value=e},setHiddenInputValue(e){const t=this.el.querySelector("input[type=hidden]");t.value=typeof e=="string"?e:JSON.stringify(e),t.dispatchEvent(new Event("input",{bubbles:!0}))},mounted(){this.handleEvent("reset",({id:e})=>{this.el.id===e&&(this.setSearchInputValue(""),this.setHiddenInputValue(""))}),this.handleEvent("selected",({id:e,selected:[t,s]})=>{this.el.id===e&&(this.setSearchInputValue(t),this.setHiddenInputValue(s))}),this.attachDomEventHandlers()},updated(){this.attachDomEventHandlers()}}};