onclick event is not working

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

onclick event is not working

Post by adinarayana »

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
Frenzie
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium
Contact:

Re: onclick event is not working

Post by Frenzie »

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.
ig123
Posts: 1
Joined: December 25th, 2014, 2:39 pm

Re: onclick event is not working

Post by ig123 »

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.
User avatar
Alice0775
Posts: 2818
Joined: October 26th, 2007, 11:25 pm
Location: OSAKA

Re: onclick event is not working

Post by Alice0775 »

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