Tuesday, February 21, 2012

IE double click on List Select Option


I recently came across a very strange issue in IE. The requirement was adding a action on select option double click of a list. The double click is working fine for all other controls in IE but was not working in case of select option.
In Mozilla & Chrome below code working as expected --

$("#list1").find("option").unbind('dblclick');
$("#list1").find('option').dblclick(function(){
//put your code here whatever needed on double click
});

but IE not able to get the double click on select option & not performing the action as other browsers. I did some Rnd on the issue but haven;t got any solution, even in some post mentioned that this is not supported on IE.
I am thankful to my friend Kapil Choudhary who help me to fix this issue. Here is the script for IE which will work on all browsers perfectly.

$("#list1").unbind('dblclick');
$("#list1").dblclick(function () {
$("#list1").find('option:selected').each(function() {
//put your code here whatever needed on double click
});
});