When I got an AJAX Webform with submission settings "redirect" on a certail page, Internet Explorer won't redirect. All other browsers work just fine.
What happens?
Well, on a successful submit, the AJAX request loads the file ajax_responder.js from CTools and then invokes some Drupal "commands". The last command is "redirect" which gets added to the DOM by said ajax_responder.js.
However, in Internet Explorer, the Block to add these commands to the prototype is NOT executed, because it's wrapped in a jQuery function object:
// Hide these in a ready to ensure that Drupal.ajax is set up first.
$(function() {
Drupal.ajax.prototype.commands.attr = function(ajax, data, status) {
$(data.selector).attr(data.name, data.value);
};
.....
What was wrong (or however what fixed the problem) was not to execute it as a jQuery function, but add it as a Drupal behaviour and let Drupal do the work:
Drupal.behaviors.ctools_add_ajax_responder_commands = {
attach:function() {
Drupal.ajax.prototype.commands.attr = function(ajax, data, status) {
$(data.selector).attr(data.name, data.value);
};
.....
You may find my patch in comment #2. Please take a look at it and comment wether this is the proper solution for that case or not.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 2889951-13.patch | 1.62 KB | shubham.prakash |
| #7 | 2889951-7.patch | 1.71 KB | mohit1604 |
| #2 | 2889951_2_Fix_redirect_not_executed_in_IE.patch | 1.91 KB | florianmuellerch |
Comments
Comment #2
florianmuellerchComment #3
florianmuellerchComment #4
mustanggb commentedThis fixed ajax reload not working after enabling jQuery3.
I won't RTBC as I've not looked into it enough to know if this is the best fix, i.e. what the consequences/downsides are.
Also your patch is malformed.
But good job, it's working for me for now.
Comment #5
skylord commentedSuffered from the same issue in Chrome with jQuery 1.10 from jquery_update. Misteriously all worked fine for admin user and not for usual one - have no time to investigate but that patch helped. Thanks!
Comment #6
joelpittetLooks like this needs a reroll. At first glance this looks like it was going in the right direction but need to look closer after it's rerolled.
Comment #7
mohit1604 commentedThis should work fine :)
Comment #8
mohit1604 commentedComment #9
travis-bradbury commented#7 solves my problem of ctools ajax redirect not working after updating to jQuery 3.3.1.
Cleanup up tags per issue tag guidelines.
Comment #10
rivimeyComment #11
torotil commentedI have the same problem with Chromium 73 and jQuery 1.7.2: The ajax commands are not defined after the ajax-responder.js is loaded. The patch solves the issue for me as well.
This is definitely not limited to jQuery 3 or Internet Explorer. I made the issue title less specific.
Comment #12
mustanggb commentedPatch works, but there is an unnecessary change to the comment:
Comment #13
shubham.prakash commentedFixed the commented line as mentioned in #12.
Comment #14
mustanggb commentedAwesome!
Comment #15
joelpittetMinor code standard spacing around attached on commit. Thanks for fixing this up, it's now on the dev branch which will be released likely today.
Comment #17
joelpittetComment #18
joelpittet