Double-click event on list option does not fire in IE

I want to bind the event to the option tags in the list box so that when I click on one of them it will move to another list.

I have this code:

$('#' + opts.leftListId + ' > option').live('dblclick', function () { // Move the object }); 

Works great in Firefox, but in IE the event doesn't fire at all. I can not double-click on the node selection, because I need to move only the one that was clicked. Any ideas?

+6
jquery internet-explorer events listbox double-click
source share
3 answers

Try this instead:

 $('#' + opts.leftListId).find('option').each(function(){ $(this).live('dblclick', function () { // Move the object }); }); 

Update (10:21 GMT)

Try to output live:

 $('#' + opts.leftListId).find('option').each(function(){ $(this).dblclick( function () { // Move the object }); }); 

See this example - http://jsfiddle.net/hr7Gd/

Update (10:45 GMT)

Another option is to run dblclick() on the select element (which works!), And get the vale value from this option and work with this:

 $("select").dblclick(function () { var str = ""; $("select option:selected").each(function () { str += $(this).text() + " "; }); $("span").text(str); }) .trigger('change'); 

See this example working here - http://jsfiddle.net/hr7Gd/1/

+6
source share

Doubleclick does not start, i.e. if you try to add them to parameter elements, no matter how you add it. The only thing I work in IE is to add an event calendar to the element itself, and then look at the selected elements:

 $("select").dblclick(function () { $("select option:selected").each(function () { alert(this); }); }); 
+7
source share

Got it - I was wrong in thinking that I could not use the double-click event.

This is the working code:

 $('#' + opts.leftListId).dblclick(function () { // Move selected options: $('#' + opts.leftListId + ' :selected') }); 

The reason I didn’t think this would work is because I thought that it would move through all the selected items, not just the clicked one. However, it seems that the first double-click click selects only one item before this event fires with a double click and moves it.

+3
source share

All Articles