I'm creating a select List from a getJson call.
in firefox / chrome the select list is generated very quickly but in ie (tested in ie8) it takes some seconds to create the options.
There is approx 2000 options being added to the select list
My code is below
function getPractitioners(practID, selectID) {
selectID = '#' + selectID;
$.getJSON("/practitioner/getPractitioners", { practID: practID }, function (fooList) {
$(selectID).empty();
$.each(fooList, function (i, foo) {
if (foo.profID == practID) {
$(selectID).append(('<option value=\'' + foo.profID + '\' selected=\'selected\'>' + foo.display + '</option>'));
}
else
{
$(selectID).append(('<option value=\'' + foo.profID + '\' >' + foo.display + '</option>'));
}
});
$(selectID).trigger("liszt:updated");
});
}
Can anybody suggest anything to improve this?
Previously I was adding the options like
$(selectID).append(("<option></option>").attr("value", foo.profID).attr("selected", "selected").text(foo.display));
but changing this did not improve the performance.
Thank you in advance.