Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
In flag_flag_link(), drupal_get_destination() will return destination=system/ajax instead of the path to the page if flag links are part of an AJAX request.
So instead of
/flag/confirm/flag/signup/18?destination=my-destination
the link href ends up being
/flag/confirm/flag/signup/18?destination=system/ajax
which returns the user to a blank page.
Similar issue for a different module reported here: http://drupal.org/node/1021328
This also seems related: http://drupal.org/node/1181370. Core issue, perhaps?
Comments
Comment #1
osopolarSeems that in ajax calls the flag module can't use drupal_get_destination() to define the destination.
Workaround 1: Append a destination parameter the ajax-call like q=system/ajax&destination=my-destination. If destination is set it will just be returned by drupal_get_destination().
Workaround 2: Implement hook_flag_link_types() and hook_flag_link() by a custom module and use something different for drupal_get_destination() in hook_flag_link().
I have no good idea how a fix should work. I guess drupal_get_destination() needs to be fixed somehow (i.e. send the current path in the request ... see http://api.drupal.org/api/views/includes!ajax.inc/function/views_ajax/7).
[Edit:] Fix typo.
Comment #2
nagiek CreditAttribution: nagiek commentedHi,
I want to do the same thing over in #1491820: Store drupal_get_destination before the modal sets q. Going to follow your issue as well to see if there are any developments.
Comment #3
joachim CreditAttribution: joachim commentedComment #4
jamesdixon CreditAttribution: jamesdixon commentedHere's another hacky workaround stealing views code from the example linked to in #1. I used this in my ajax call before calling flag_create_link()
I also had to include the flag module's js from the ajax success call: