Vlad Nicula
Vlad Nicula

Reputation: 3696

Why won't Internet Explorer 9 react to this click event? [short jsFiddle code inside]

Problem solved. Solution below.

It's been long since I tried to do this in pure javascript without jquery, but take a look: http://jsfiddle.net/agilius/mKmTA/2/

It's a simple select list where double clicking an item moves it to the destination list. I wrote a bind function that detects if the object has addEventListener or attachEvent. jQuery does the same thing here https://github.com/robflaherty/jquery-annotated-source/blob/master/jquery-1.6.2/07-event.js#L118

Upvotes: 2

Views: 597

Answers (2)

Pointy
Pointy

Reputation: 413720

Internet Explorer doesn't think that "click" events happen on <option> elements. Instead, they fire on the parent <select>.

Also of course @SLaks noted the bug in the event handler "bind()" function.

edit — another problem you may have is that this won't be set for you in IE (I think; it's not in IE8 anyway).

Upvotes: 3

SLaks
SLaks

Reputation: 887405

You're checking for target.addEventListener rather than target.attachEvent in the second if.

Upvotes: 2

Related Questions