Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Nummer anzurufen, sie per SMS zu kontaktieren oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Learn More

The change event is not firing when bound to a input text field in FF 15

  • 30 Antworten
  • 23 haben dieses Problem
  • 10986 Aufrufe
  • Letzte Antwort von Mygind

more options

$("#dealer-warranty-parts-percent").bind('change', function(){ data.partsPercent = $(this).val(); AMMS.dealerWarrantyModified = 1; });

This code will not fire in the latest (FF 15) version of FF but does fire in the previous version. I am now having to switch to blur event.

Ausgewählte Lösung

Never mind after further digging in the code there appears to be an issue with binding the keyup event that was deeper in the code that appears to be the ultimate culprit.

Diese Antwort im Kontext lesen 👍 0

Alle Antworten (20)

more options

I don't see that mentioned in this article as an intentional change: https://developer.mozilla.org/en-US/docs/Firefox_15_for_developers

When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.

1. Bypass Firefox's Cache

Use Ctrl+Shift+r to reload the page fresh from the server.

If you are using a remotely hosted copy of jQuery (etc.) you might also clear Firefox's cache completely:

orange Firefox button or Tools menu > Options > Advanced

On the Network mini-tab > Cached Web Content : "Clear Now"

2. If needed, remove your site's cookies in this dialog

While viewing a page on the site, right-click and choose View Page Info > Security > "View Cookies"

Then try reloading the page. Does that make any difference?

more options

Any errors in the Web Developer > Error Console (Ctrl+Shift+J)?

more options

The below code does not work.

<input id='test' onchange='alert("test")' />

Any ideas?

more options

I tried clearing the cache as recommended as well as the cookies and I am still getting the same behavior. I am not seeing any error is the Error console relating to to this.

The above code is functioning correctly in Chrome.

more options

Does the event fire when you tab out of the control? That is what is supposed to happen per W3C DOM Level 2:

change
The change event occurs when a control loses the input focus and its value has been modified since gaining focus. This event is valid for INPUT, SELECT, and TEXTAREA. element.

more options

Do you have a test page with that code?


carmijac

Works for me on Linux.

data:text/html;charset=utf-8,<input id='test' onchange='alert("test")' />
more options

Changing the event from onchange to onblur worked for me

more options

"Changing the event from onchange to onblur worked for me "

That is the fix that I have placed into the code. I am trying to determine exactly what broke the code between version 14 and version 15.

Geändert am von rlm1966

more options

Anyone know what changed from 14 to 15?

more options

Ausgewählte Lösung

Never mind after further digging in the code there appears to be an issue with binding the keyup event that was deeper in the code that appears to be the ultimate culprit.

more options

I have the same problem, does not fire the event and error consoloa shows no error, the strangest thing is that if no events are fired onChange in version 14.01 and earlier worked without problem

more options

in my forms use iniTodo function (http://javascript.espaciolatino.com/scripts/editinputnume.htm) to format a number while typing, this seems to affect the operation of onChange, seems a bug in Firefox since the previous versions had no problem with that, and in the other browsers it works without problem

more options

Hi rchicangana, your function binds to onkeyup. Does it work with onkeyup? Is there a different function that you are binding to onchange?

more options

if it seems onkeyup problems, I have another function to mask the dates and also when typing text on the field is no longer running the onchange, report it in bugzilla

more options

Using FireFox 15.0.1:

In the following code the "onChange" event does not fire with the tab key, but will fire when the mouse click is used to advance the cursor.

 td.innerHTML = '<input '+
     'type="text" '+
     'id  ="JOBID_'+cNextLine+'" '+
     'name="JOBID_'+cNextLine+'" '+
     'class="InputText" '+
     'size ="7" '+
     'maxlength="6" '+
     'onfocus="turnOnSearch(this);" '+
     'onKeyPress="this.value = this.value.toUpperCase(); return loadPhaseCoder(event, this);" '+
     'onchange ="if (cSetLoc(this)) {isNotEmpty(this); getPrjct(this); DataChanged();}" '+
     'onblur = "if (cSetLoc(this)) {updateJobId(this); turnOffSearch();}" '+
     '/> ';

Likewise the same is true for this code using the "addEventListner"

 g.getClient = document.getElementById('ID');
 if (g.getClient.addEventListener)
 {
  g.getClient.addEventListener("change",g.requestClient,false);
 }

This code has been running since 2009 with no problems right up to version 14.1

It will be good to know when FireFox fixes the problem. It should be noted the code still works in Google's Chrome.

Geändert am von cor-el

more options

Hi Mygind, are there any new errors in Firefox's Error Console (Ctrl+Shift+j) that you did not get in Firefox 13 or earlier? Also, can you tell whether Firefox is firing the events in a different order than before? I would think that for a click away you would get blur then change, and on tab you would get keypress then blur then change. However, I haven't tested/compared.

more options

I have the same problem.
Reproduce:
1. Load a html page with a text input.
2. Open <strike>Firefox</strike> Firebug - html tab - select the input box - right click - log events
3. Go to the console tab
4. Click on the input, give same value and press tab or click out
Firebug will show all the events except the "change"

Actually I tried the same with this page, with the search input and it worked. I do not have time to dig into it more. Maybe because this page is HTML5 and I had the problem with a XHTML 4 Transitional page.


[corrected formatting and changed Firefox -> Firebug -c]

Geändert am von cor-el

more options

Hi rrd108, I think you meant Firebug. When I perform that test using the search box at the top of the page, I get change fired before blur when I tab over to the submit button.

By the way, thank you for pointing out this method of investigating the sequence of events, it's really handy.

Geändert am von jscher2000

more options

Yes, sorry I meant Firebug. And yes it gives change event on this page, but does not give on my web app. That is why I thought it is because of the doctype, but I did not have time to investigate more.

more options

I just upgraded to Firefox 15.0.1 and still change event do not fires.

  1. 1
  2. 2