When an $element exists, the #attached array should be used to include JavaScript and CSS. Otherwise, there is a possibility of pages loading as broken when JS aggregation or Ajax modal windows are used.

The included patch resolves this by replacing each drupal_add_js and drupal_add_library with its proper code for #attached.

The one place I did not modify drupal_add_js is in ajax_facets_views_pre_render, which I will address in a separate issue.

Please review, thanks.

Comments

ron_s created an issue. See original summary.

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

this change should go in please.

narkoff’s picture

Successfully tested patch #1, no issues.

i.koychev’s picture

The patch works for me after changing the
$element['#attached']['library'] = array('system', 'drupal.ajax');
with
$element['#attached']['library'][] = array('system', 'drupal.ajax');
Otherwise an error occurs: Uncaught TypeError: Drupal.ajax is not a constructor.

sgdev’s picture

StatusFileSize
new4.7 KB
new339 bytes

Thanks, that's a fine change to make. Updated patch and interdiff are attached.