I am using Select2 extensively. I am trying to run $('html,body').scrollTop() function inside Select2 .on('change') event but it doesn't work properly. My code:
$('.category_select').on('change', function(e){
var scroll_pos = $('#category_'+$(this).select2('val')).offset().top;
$('html,body').scrollTop(scroll_pos);
});
If the scroll position is larger then top offset of select2 element then select 2 will reposition scroll so that select2 element remains visible. How can I go around this?
UPDATE:
I have created fiddle that shows this problem http://jsfiddle.net/83acq8hp/2/. This issue is only existing in Firefox. In Safari and Chrome it works normally, but in Firefox as the fiddle shows not.