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: -
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"
-
/>
- This button when clicked fires twice
-
<input
-
type="button"
-
id ="sbComClient"
-
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. -
- For button 2 in app 2 this eventlistener fires twice.
-
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)
-
}
-
- Here is code from app1 which fires properly so you can see all the code involved
-
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)
-
}
-
-
-
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 found the error. The one button firing twice had the event listener defined twice. Too much copying of the code. Well there goes 2 hours of my life that could have been spent better.
1 7367
I found the error. The one button firing twice had the event listener defined twice. Too much copying of the code. Well there goes 2 hours of my life that could have been spent better.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jonas Nilsson |
last post by:
Hi!
I have a DataList with some linkbuttons, and when i click them the
eventhandler fires twice.
Is there a way around this?, it's the same problem with the repeater and
datagrid control...
|
by: Jay Douglas |
last post by:
Hello all,
I have a asp.net page that creates a pdf on the fly and sends the pdf
down to the browser. When calling the page up in IE the Page_Load event is
fried twice. This doesn't happen with...
|
by: Asa Monsey |
last post by:
I am having a problem that the page load event fires twice in reponse to an
autopostback. The first time, the IsPostBack property is true, and the
second time it it false. This is causing many...
|
by: Jim Heavey |
last post by:
Why does the method for on_ItemCommand fire twice when I press a button
contained within my grid?
My dgTask_ItemCommand which is the procedure name assigned to the
"on_ItemCommand" fires twice...
|
by: Bill Manring |
last post by:
The startup page for my ASP.NET application is an HTML frames page with two
frames. This seems to cause the Session_Start event in the Global.asax file
to fire twice. When I change the startup...
|
by: JeffM |
last post by:
This seems odd, but it appears that the Page_Unload event is fired twice on a
Response.Redirect or a Server.Transfer.
The output below demonstrates that during the move from the first to the 2nd...
|
by: doctorle |
last post by:
I'm surprised that the Current event of forms always fires twice
(Access XP).
I have quite a lot of processing done in the current event, how to make
the code run just once?
Thanks
|
by: docw |
last post by:
SelectionChangeCommitted event fires twice
Hi,
Please have a look at the following ComboBox behavior.
With the code below, if you click in the dropdown list with the mouse
to select an item ,...
|
by: Simon Harvey |
last post by:
Hi Guys,
Can anyone tell me why the DataGridView.SelectionChanged event fires
twice when I databind to it.
If I do the following, the first row is selected automatically, but the
changed...
|
by: manywolf |
last post by:
I have an aspx page that fires the page load event twice for every load. I tried every fix that was suggested in all the posts on this and other forums. None changed the behavior. After one post that...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |