Search code examples
javascriptdom-eventsinternet-explorer-9

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


Solution

  • 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).