onclick event is not working

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Posts: 1
Joined: December 16th, 2014, 6:08 am

Post Posted December 16th, 2014, 6:14 am

I have the following scenario in my project:

In the form the following field is there:
Code: Select all
Name : <input type="text" onchange="callSyncAjax(this)" /><input type="button" onclick="doSave()" value="Save"/>

In the java script :

Code: Select all
     function callSyncAjax(obj) {
        //some syncronized ajax function here return true;

  function doSave() {
   //form submit functionaly here

Now i enter some name in name field and with out clicking any where or without tabbing i clicked on save button but in Fire Fox the doSave() function is not called. But i clicked again then its called.

can any one help on this? why for first time the doSave() method not called?


User avatar
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium

Post Posted December 17th, 2014, 12:45 pm

Without a minimal testcase I doubt anyone will be able to say anything sensible about it.
Intelligent alien life does exist, otherwise they would have contacted us.

Posts: 1
Joined: December 25th, 2014, 2:39 pm

Post Posted December 25th, 2014, 2:47 pm

I am seeing a similar issue. In my case, the onchange handler does some DOM manipulation (appends to a div) and this seems to confuse event handling. In firebug, when I click on the button I see a mousedown event on the button, then the change event then a mouseup event on the input. The mouseup event is on the input rather than the button even though the cursor hasn't moved. Since the mousedown and mouseup are not on the same element (the button), there is no change event on the button. If I don't manipulate the DOM, then it works as expected. So, you might check your events in a bit more detail to see if your case is similar.

Posts: 2765
Joined: October 26th, 2007, 11:25 pm

Post Posted January 16th, 2015, 6:28 pm

sync XHR + event handling is inconsistent in all the browsers in various ways.
And sync XHR is deprecated in the main thread.

Return to Web Development / Standards Evangelism

Who is online

Users browsing this forum: No registered users and 1 guest