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.
Comment | File | Size | Author |
---|---|---|---|
#1 | rel-load-js-as-libraries-1532566-1.patch | 997 bytes | damontgomery |
Comments
Comment #1
damontgomery CreditAttribution: damontgomery commentedComment #2
damontgomery CreditAttribution: damontgomery commentedWell, 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,
to
Comment #3
itaine CreditAttribution: itaine commentedThank you pandaeskimo. I nearly threw away the admin and box modules over this. Simple documentation resolves this issue.
Comment #4
swentel CreditAttribution: swentel commentedAdded the documentation, thanks!
Comment #6
sinasalek CreditAttribution: sinasalek commentedIs 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
Comment #7
sinasalek CreditAttribution: sinasalek commented