diff -u b/media_multiselect.js b/media_multiselect.js --- b/media_multiselect.js +++ b/media_multiselect.js @@ -32,8 +32,19 @@ uploadField.val(files[i].fid); uploadField.trigger('change'); - // Find the attach button and automatically trigger it. + // Find the attach button. var attachButton = uploadField.siblings('.attach'); + + // Add a new beforeSerialize to avoid AJAX HTML IDs. + Drupal.ajax[attachButton.attr('id')].beforeSerialize = function(element, options) { + options.data['ajax_page_state[theme]'] = Drupal.settings.ajaxPageState.theme; + options.data['ajax_page_state[theme_token]'] = Drupal.settings.ajaxPageState.theme_token; + if (Drupal.settings.ajaxPageState.jquery_version) { + options.data['ajax_page_state[jquery_version]'] = Drupal.settings.ajaxPageState.jquery_version; + } + }; + + // Trigger the attach button. Drupal.ajax[attachButton.attr('id')].options.async = false; attachButton.trigger('mousedown'); }