I ran into an issue where ajax.js is being loaded directly by Rel instead of as a library. This resulted in it loading after views/js/ajax_view.js and causing issues.

This happens when you check "Enable form registration" at /admin/structure/rel/config. The current solution is to disable this after registering forms.

My specific issue was that uploading a YouTube video as a field using the new Media, File Entity, and Media YouTube modules would cause many of the AJAX functions to break on the page. Fields inside of Field Collections that had this issue would not even save to the node.

I present the following solution, replacing

drupal_add_js('misc/ajax.js');

With,

drupal_add_library('system', 'drupal.ajax');

Similarly,

$form['#attached']['js'][] = 'misc/form.js';
$form['#attached']['js'][] = 'misc/collapse.js';

With,

$form['#attached']['library'][] = array('system', 'drupal.collapse');

Collapse library is dependent on form.js, so it will load automatically.

patch to follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damontgomery’s picture

Status: Active » Needs review
FileSize
997 bytes
damontgomery’s picture

Well, it didn't actually fix all the issues I'd thought.

The JS error did go away but with the "Enable form registration", I'm still having the problems with adding a YouTube video and losing the ability to save it or add / delete field collections.

I'm really not sure why this is happening, but disabling that part of rel when not needed solves the issue.

This may be such a niche case that it's not worth looking into. On the other hand, I would re-write the description of that option as follows,

Users with the 'rel_build_registration' permission will see a "Manage form display" link on any form in the site, unless it appears on a path which has been excluded underneath.

to

This option enables "Manage form display" links on forms throughout your site. These links are used to add these forms to the list of "Renderable Elements" listed in the "Renderable Elements" tab. Once a form has been added, you can use the "Renderable Elements" tab to manage the form display options and to unregister the form.

It is recommended that you enable this option when registering forms and then disable this option after you have added the forms to the "Renderable Elements" list. When enabled, this option may conflict with other modules. Disabling this options after forms have been registered will not remove them from the "Renderable Elements" list in the "Renderable Elements" tab.

You may prevent these links using specific exclusion rules below.

itaine’s picture

Thank you pandaeskimo. I nearly threw away the admin and box modules over this. Simple documentation resolves this issue.

swentel’s picture

Status: Needs review » Fixed

Added the documentation, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sinasalek’s picture

Issue summary: View changes

Is this committed ? There is still drupal_add_js('misc/ajax.js'); in dev version
which should be replaced with drupal_add_library('system', 'drupal.ajax');
Another issue #2431107: Causes error: TypeError: D.ajax is undefined jquery_update.js:2

sinasalek’s picture

Status: Closed (fixed) » Needs work