I am baffled as to why an event listener is firing twice on me.
I have two apps that share the same piece of code. Each app has two search buttons, So a total of 4 search buttons. Each executing the same code with different parameters. Of the 4 buttons only one fails by firing twice on a single click.
Here are the buttons as coded in the two apps:
Each button is assigned an event listener like so. I copied this code from the one app to the other app, so the code is identical.
From this point forward all 4 buttons run the exact same code from linked files.
Where should I be looking for the cause of the problem?
What are some possible explanations for multiple firings? I understand double click and that is not the problem, I have checked that.
I have two apps that share the same piece of code. Each app has two search buttons, So a total of 4 search buttons. Each executing the same code with different parameters. Of the 4 buttons only one fails by firing twice on a single click.
Here are the buttons as coded in the two apps:
Code:
from App1: <input type="button" id ="sbReqClient" value="Change Client" class="InputText" tabindex="-1" /> <input type="button" id ="sbComClient" value="Change Client" class="InputText" tabindex="-1" /> from App2: <input type="button" id ="sbReqClient" value="Change Client" class="InputText" tabindex="-1" /> [B]This button when clicked fires twice[/B] <input type="button" id ="[B]sbComClient[/B]" value="Change Client" class="InputText" tabindex="-1" />
Each button is assigned an event listener like so. I copied this code from the one app to the other app, so the code is identical.
Code:
[B]For button 2 in app 2 this eventlistener fires twice.[/B]
g.sbComClient = document.getElementById('sbComClient');
if (g.sbComClient.addEventListener)
{
g.sbComClient.addEventListener("mousedown",
function(evt)
{
[B]smallSearch[/B]('Client Id','10','8','CLIENT','ID','ComClient','Yes','startSmallSearch');
},
false)
}
g.sbReqClient = document.getElementById('sbReqClient');
if (g.sbReqClient.addEventListener)
{
g.sbReqClient.addEventListener("mousedown",
function(evt)
{
smallSearch('Client Id','10','8','CLIENT','ID','ReqClient','Yes','startSmallSearch');
},
false)
}
[B]Here is code from app1 which fires properly so you can see all the code involved[/B]
g.sbComClient = document.getElementById('sbComClient');
if (g.sbComClient.addEventListener)
{
g.sbComClient.addEventListener("mousedown",
function(evt)
{
smallSearch('Client Id','10','8','CLIENT','ID','ComClient','Yes','startSmallSearch');
},
false)
}
g.sbReqClient = document.getElementById('sbReqClient');
if (g.sbReqClient.addEventListener)
{
g.sbReqClient.addEventListener("mousedown",
function(evt)
{
smallSearch('Client Id','10','8','CLIENT','ID','ReqClient','Yes','startSmallSearch');
},
false)
}
Where should I be looking for the cause of the problem?
What are some possible explanations for multiple firings? I understand double click and that is not the problem, I have checked that.
Comment