问题
We're using jQuery UI MultiSelect widget on our website for various fields. For consistency we use it even for non-multi selects. The example code we use is:
jQuery('#model').multiselect({
multiple : false,
minWidth : 'auto',
height : 'auto',
header : false,
selectedText: multiselect_set_label,
open : multiselect_fit_widget,
close : multiselect_free_keyboard,
create : multiselect_fit_label,
beforeopen : multiselect_bold_options
});
Its not completely same everywhere, so we can't have just one setup for all multiselects. (If it was same everywhere I'd make a single initialization and try anonymous functions)
IE8 throws up the error "'multiselect_set_label' is undefined" (or multiselect_fit_widget or some other function).
That function is defined as follows:
function multiselect_set_label(selected, total, elements)
{
/* lots of code here */
}
I also tried changing it to this:
var multiselect_set_label = function(selected, total, elements)
{
/* lots of code here */
}
But the problems persist (I did clear cache between attempts).
Throughout testing all other browsers work fine, and since IE8 accounts for only 1.8% of our visitors this is not a burning problem for us, so if there's no simple solution I'll just ignore it. But if this can be solved it would be nice because our site is currently not usable at all on IE8. (I am aware that the reason for low percentage of IE 8 visitors might be because of the problems but we also don't have any visitor complaints)
来源:https://stackoverflow.com/questions/18461685/javascript-functions-dont-work-in-ie8-when-passed-as-parameters