1
0
mirror of synced 2024-11-26 06:46:04 +03:00

close any opened select2s when the window is scrolled or resized. fixes #296 and potentially #149

This commit is contained in:
Igor Vaynberg 2012-08-04 11:28:02 -07:00
parent bc9867af0b
commit a7d0849d23

View File

@ -400,6 +400,10 @@
throw new Error("formatterName must be a function or a falsy value");
}
function evaluate(val) {
return $.isFunction(val) ? val() : val;
}
/**
* blurs any Select2 container that has focus when an element outside them was clicked or received focus
*
@ -429,9 +433,20 @@
});
});
function evaluate(val) {
return $.isFunction(val) ? val() : val;
}
/**
* Closes any opened Select2s when the window is resized
*/
$(window).resize(debounce(100, function() {
$(".select2-container.select2-dropdown-open").select2('close');
}));
/**
* Closes any opened Select2s when the window is scrolled
*/
$(window).scroll(debounce(100, function() {
$(".select2-container.select2-dropdown-open").select2('close');
}));
/**
* Creates a new class