1
I have a Dropdownbutton made in Css, follow the html code:
<html>
<head>
<link href="./mainScreen.css" rel="stylesheet" />
<script src="./mainScreen.js"></script>
</head>
<body>
<div class="dropdown">
<button onclick="dropdown()" class="dropbtn">Ordem de Serviço</button>
<div id="myDropdown" class="dropdown-content">
<a id="create">Criar nova</a>
<a id="list">Listar pendências</a>
<a id="search">Pesquisar</a>
<a id="close">Fechar</a>
</div>
</div>
</body>
</html>
I want when one of these options is selected, a function in a JS file is execuated, so I can perform IPC communication from Electron and open the new system page.
Follows the current JS code. I was trying to run before the " onclick='osRequest()' ", but it would probably run completely because of the checks:
function osRequest() {
if (document.querySelector("a#create")) {
ipcRenderer.send("os:create");
}
if (document.querySelector("a#search")) {
ipcRenderer.send("os:search");
}
if (document.querySelector("a#close")) {
ipcRenderer.send("os:close");
}
if (document.querySelector("a#list")) {
ipcRenderer.send("os:list");
}
}
i would have to create a file for each function and use href on each button?
– Mdsp
You tried to use the
addEventListener
?– Luiz Felipe
How would you use it exactly? Like, beyond the basics...
– Mdsp
To documentation is a good place to start.
– Luiz Felipe