I think I did it! :)
The goal is to prevent any other propagation in the optiontag mousedownand manually control the focus of the field select.
See jsFiddle
I tried to make this as clear as possible:
$('option')
.on('mousedown', function(e){
e.stopImmediatePropagation();
$(this)
.parents()
.filter(function(){
return $(this)[0].scrollHeight > $(this)[0].clientHeight;
})
.each(function(_,elt){
$(elt).data('saveScroll', $(elt).scrollTop());
})
$(this).parent('select')
.trigger('focus')
.trigger('scrollback');
});
$('select')
.on('scrollback'
, function(e){
$(this)
.parents()
.filter(function(){
return 0 === $(this).data('saveScroll') || ~~$(this).data('saveScroll');
})
.each(function(_,elt){
$(elt).scrollTop($(elt).data('saveScroll'));
$(elt).removeData('saveScroll');
})
});
This is probably not ideal because it is a hack.
At least he even worked with multiple-typed select. And it is cross-browser compatible.
source
share