As mentioned on Skype with fubhy, modified omega_js_alter to remove ajaxPageState if the misc/ajax.js file isn't included in the JS files. Small modification in omega_get_js too as that forcefully adds it partially back.

In terms of my testing, I've played around with pages that do use the AJAX system and they still work fine (and contain the ajaxPageState settings on the page). Anyone with access to more complex sites may want to test this...

Patch in #1...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mjpa’s picture

The patch...

attiks’s picture

#1 Patch looks good


+++ b/template.phpundefined
@@ -315,6 +315,20 @@ function omega_css_alter(&$css) {
+  if ( ! isset($js['misc/ajax.js']) && isset($js['settings']['data'])) {

no space after !

PS: Can you have a look at #1279226: jQuery and Drupal JavaScript libraries and settings are output even when no JS is added to the page it will add major improvements on mobile

msmithcti’s picture

Assigned: Unassigned » msmithcti

I have a site which makes heavy use of the AJAX commands and AJAX in the FAPI. Assigning to me so I remember to review this at some point.

fubhy’s picture

Status: Needs review » Reviewed & tested by the community

Let's do this. Just tried it and seems to work. Can you take a final look @splatio and then commit it?

msmithcti’s picture

Assigned: msmithcti » Unassigned
Status: Reviewed & tested by the community » Fixed

Works great for me. Committed in b3c106c and pushed.

Thanks!

Status: Fixed » Closed (fixed)

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

fubhy’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

Nope, this does not work. This currently causes a bug with the Edit module. This is a very rare case but we CAN'T just remove this stuff as it seems to be required when a script adds JavaScript file as a result of the Ajax response.

So, reverting this :).

Reverted in commit 9705213.

If you find a better way of doing this without breaking modules like Edit, please provide a new patch!

Otherwise, please close as "Won't fix"

mjpa’s picture

So.. turns out this was actually pretty simple to fix!

The original patch was only checking for misc/ajax.js in the current scope (header / footer) and not the whole page.

Tested the attached patch against the latest Omega 4.x branch, Edit 7.x-1.0+3-dev and a freshly created Omega sub-theme.

mjpa’s picture

Status: Active » Needs review
justanothermark’s picture

Status: Needs review » Reviewed & tested by the community

I've tested this with Quickedit (the renamed Edit module) and can confirm the patch in #8 does not break it. Even if this isn't committed, I would recommend doing a new release now so that Omega and Quickedit are compatible with non-dev versions (the original patch was reverted after 4.2).

  • fubhy committed f44d9f7 on 7.x-4.x
    Issue #1998434 by mjpa: Remove ajaxPageState settings if they're not...
fubhy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks

joelpittet’s picture

Not exactly sure how but I believe this is breaking views ajax requests on my site because this didn't happen before the update.

It may only happen with views caching, I'll report back if I have more details.

An error occurred while attempting to process /ca/views/ajax: ajax.form.ajaxSubmit is not a function

fubhy’s picture

Status: Fixed » Active
segovia94’s picture

This causes all ajax to fail if using the Dialog API module. The Dialog API is looking for these settings that have been removed and everything falls apart.

I'm not sure what the original reasoning for removing these settings was other than just keeping things clean. Perhaps this is a little too heavy handed? I would recommend removing this patch if it doesn't really provide any benefits in regard to performance.

TypeError: Drupal.settings.ajaxPageState is undefined
options.data['ajax_page_state[theme]'] = Drupal.settings.ajaxPageState.theme;
steinmb’s picture

We never rolled this back. @fubhy do you have time to comment?

kobb’s picture

Just verifying that reverting the patch in #8 fixes the incompatibility with the Dialog API.

steinmb’s picture

Status: Active » Needs work
Pierrere’s picture

Dialog API isn't the only affected module. File Field and Drag'n Drop upload also displayed errors:

"cannot read property 'theme' of undefined" (Chrome)
- or -
"TypeError: Drupal.settings.ajaxPageState is undefined" (Firefox)

when trying to execute an ajax request. Commenting out (reverting) the patched lines in omega/template.php fixed the errors and made the functions usable.

Both errors are from the same page and the same field.

smithmilner’s picture

These settings are used by the scheduler module as well.

scheduler_vertical_tabs.js?:19 Uncaught TypeError: Cannot read property 'theme' of undefined

steinmb’s picture

Category: Task » Bug report
Priority: Normal » Major
oana.hulpoi’s picture

I can confirm that the patch #8 is breaking views ajax requests, in views exposed filters.

The errors displayed are:

cannot read property 'theme' of undefined (Chrome)
TypeError: Drupal.settings.ajaxPageState is undefined (Firefox)

Reverting the patch in #8 fixes the incompatibility.

lauramunro’s picture

Took me a very long time to figure out this was the cause of all my problems! Views exposed filters as well as file/image upload fields were just not working.... getting the above errors like everyone else:

cannot read property 'theme' of undefined (Chrome)
TypeError: Drupal.settings.ajaxPageState is undefined (Firefox)

Reverting the changes in patch #8 solved my problems