X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2FCommon.js;h=cb3c8d23704d9927abc95dd1938ec4fde536d304;hb=2a8755e6cf10e8f70270826dff1d9c7412be8b80;hp=63db35419386429c233873a266a33656c1ca280a;hpb=c5afdcccabe7d15c1e1f2e3255a094e5f2a560db;p=civicrm-core.git diff --git a/js/Common.js b/js/Common.js index 63db354193..cb3c8d2370 100644 --- a/js/Common.js +++ b/js/Common.js @@ -436,11 +436,26 @@ if (!CRM.vars) CRM.vars = {}; formatResult: formatCrmSelect2, formatSelection: formatCrmSelect2 }; + // quickform doesn't support optgroups so here's a hack :( + // Instead of using wrapAll or similar that repeatedly appends options to the group and redraw the page (=> very slow on large lists), + // build bulk HTML and insert in single shot + var optGroups = {}; $('option[value^=crm_optgroup]', this).each(function () { - $(this).nextUntil('option[value^=crm_optgroup]').wrapAll(''); + var groupHtml = ''; + $(this).nextUntil('option[value^=crm_optgroup]').each(function () { + groupHtml += this.outerHTML; + }); + optGroups[$(this).text()] = groupHtml; $(this).remove(); }); + var replacedHtml = ''; + for (var groupLabel in optGroups) { + replacedHtml += '' + optGroups[groupLabel] + ''; + } + if (replacedHtml) { + $el.html(replacedHtml); + } // quickform does not support disabled option, so yet another hack to // add disabled property for option values @@ -741,6 +756,7 @@ if (!CRM.vars) CRM.vars = {}; } markup += '
' + (row.color ? ' ' : '') + + (row.icon ? ' ' : '') + _.escape((row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : '')) + '
' + '
';