github.com/secoba/wails/v2@v2.6.4/pkg/templates/generate/plain/frontend/src/main.js (about) 1 // Get input + focus 2 let nameElement = document.getElementById("name"); 3 nameElement.focus(); 4 5 // Setup the greet function 6 window.greet = function () { 7 // Get name 8 let name = nameElement.value; 9 10 // Check if the input is empty 11 if (name === "") return; 12 13 // Call App.Greet(name) 14 try { 15 window.go.main.App.Greet(name) 16 .then((result) => { 17 // Update result with data back from App.Greet() 18 document.getElementById("result").innerText = result; 19 }) 20 .catch((err) => { 21 console.error(err); 22 }); 23 } catch (err) { 24 console.error(err); 25 } 26 }; 27 28 nameElement.onkeydown = function (e) { 29 if (e.keyCode == 13) { 30 window.greet(); 31 } 32 };