Commit fc30a0e1 authored by Steven Jones's avatar Steven Jones Committed by joseph.olstad

Issue #2842446 by dsnopek, Steven Jones: Media widget that gets AJAX reloaded will stop working

parent 1a461813
......@@ -828,11 +828,16 @@ function media_element_process($element, &$form_state, $form) {
// Media browser attach code.
$element['#attached']['js'][] = drupal_get_path('module', 'media') . '/js/media.js';
// IDs of form elements are 'unstable' in Drupal because of drupal_html_id
// add a class for our Javascript instead.
$element_js_class = drupal_html_class('js-media-element-' . $element['#id']);
$element['upload']['#attributes']['class'][] = $element_js_class;
// Add the media options to the page as JavaScript settings.
$element['browse_button']['#attached']['js'] = array(
array(
'type' => 'setting',
'data' => array('media' => array('elements' => array('#' . $element['#id'] => $element['#media_options'])))
'data' => array('media' => array('elements' => array('.' . $element_js_class => $element['#media_options'])))
)
);
......
......@@ -915,7 +915,7 @@ class MediaElementSettingsTestCase extends MediaFileFieldTestCase {
$multiselect = ($field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED);
$field_widget = array(
'elements' => array(
'#edit-' . $field_name . '-' . LANGUAGE_NONE . '-0-upload' => array(
'.js-media-element-edit-' . $field_name . '-' . LANGUAGE_NONE . '-0-upload' => array(
'global' => array(
'types' => array(
'image' => 'image',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment