Jason
Jason

Reputation: 4695

Odd problem with jQuery .change() event

I have the following select element with an onchange event.

<select name="ftest" onchange="alert('test');">
  <option value="0"></option>
  <option value="test">test</option>
</select>

I later bind another event on all the select elements in the page using jQuery (1.4.4).

   $("SELECT").change(function(){
    _isDirty = true;
   });

The result is my alert showing up twice when I change the value of my select list.

Anyone has an idea why this is happening or have a way to fix this?

Thanks

Upvotes: 1

Views: 295

Answers (2)

Walt Stoneburner
Walt Stoneburner

Reputation: 2612

I believe, that jQuery adds handlers, not replaces them. So for the above, you'd get one for your onchange attribute in the SELECT element, and another for the addition that jQuery makes.

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630559

This is a known bug with IE and jQuery, due to the way they simulate bubbling for change in IE. Unfortunately, there isn't a clean work-around at the moment, besides removing the inline onchange handler.

Upvotes: 1

Related Questions