Currently "nojs" in the path is used to gracefully degrade if users don't have javascript. However, the javascript regex that replaces that with "ajax" is finicky and doesn't allow for variations in the URL, such as query parameters or fragments. Here is the list of cases it should check for:

+  // 1. /nojs/
+  // 2. /nojs$ - The end of a URL string.
+  // 3. /nojs? - Followed by a query (with clean URLs enabled).
+  //      E.g.: path/nojs?destination=foobar
+  // 4. /nojs& - Followed by a query (without clean URLs enabled).
+  //      E.g.: ?q=path/nojs&destination=foobar
+  // 5. /nojs# - Followed by a fragment.
+  //      E.g.: path/nojs#myfragment

This is a backport of #565808: nojs/ajax replacement from Drupal HEAD.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drewish’s picture

I appreciate that this moves the regex into a function. I'd be able to re-use it from Dialog module. We're currently debating what the right regex is for rewriting links. Currently it matches ctools but Dave Reid is pushing for the D7 mechanism: #1046758: Drupal.Dialog.submitAjaxForm not correctly rewriting URLs.

drewish’s picture

FileSize
84.74 KB

I poked around with panels with the debugger and seemed good to me, I couldn't find any regressions.

I rerolled the patch to remove an extra semicolons from one line:

+        url = Drupal.CTools.AJAX.urlReplaceNojs(url);;
drewish’s picture

FileSize
2.39 KB

Yeah, ignore the other 82K of that patch.

Taran2L’s picture

@drewish: thanks, seems like your patch works properly.

Blackice2999’s picture

Hi,

same strange issue here on Firefox 3.6.17 i applied the patch and the problem is still exists and firefox calls nojs instead of ajax. The interesting is if i open the firebug (only open firebug no more) it works nojs will be replaced with ajax. if i close firebug its work until a page reload... i think this is a strange firefox issue and its hard to debug it without firebug :D

regards
Dennis

Taran2L’s picture

@Blackice2999, probably you have console.log() somewhere in the code (or other console object use), without Firebug there are no console object in FF. In this case you will have uncaught JS error, which can break other code, like ctools AJAX responder.

Blackice2999’s picture

@Taran2l,

thanks alot! - thats is it. From the dialog module / dialog.js:247 ...

regards
Dennis

Dave Reid’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me if it still applies.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs review

Actually I don't like that this adds a new function - we should just replace in-line like the current code.

Dave Reid’s picture

Status: Needs review » Reviewed & tested by the community

Nevermind, I can't make up my mind.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed!

Status: Fixed » Closed (fixed)

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

Demonick99’s picture

FileSize
2.4 KB

It seems to me or in the patch and the current version of the module error in the first case the function should be passed the url, and old_url?