Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
can somebody of the views crew explain me, why the function views_ajax (line 17 in includes/ajax.inc) deletes on line 29 the 2 parameters ajax_html_ids and ajax_page_state?!?!
Because this caused me a lot of head aches the last few days! ;-)
I have quicktabs of views showing fivestar ratings. And the missing ajax_html_ids parameter caused duplicated ids and that broke the rating forms.
So if there's no reason, I'd like to ask you to exclude those 2 parameters from the used array on line 29! thanks! :-)
greets ifux
Comments
Comment #1
dawehnerJust to quote the code:
Comment #2
ifux CreditAttribution: ifux commentedokay, $_GET no problem, but why deleting it also from $_REQUEST and $_POST?!?
$_REQUEST maybe, but $_POST definitivly not!
Comment #3
dawehnerFeel free to make a patch and get people to test it.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedRemoving those lines will massively break Views' AJAX, because Drupal will helpfully increment HTML IDs that are being replaced. Once you've AJAX'ed once, the following views will fail their AJAX because the IDs no longer match. Unfortunately, Drupal's HTML ID protection system does not consider the idea that some IDs might be replaced, so you can't conditionally replace some and not others. Thus, all we can do is remove the entire set.
Comment #5
yannickooI'm loading views via AJAX and they have rendered nodes included which have a field group inside. The problem is that collapsible fieldsets are not collapsible when loading them via AJAX because the necessary files (
misc/form.js
,misc/collapsible.js
andsites/all/modules/contrib/field_group/field_group.js
) are not loaded. I debugged inajax_render
,drupal_get_css
andviews_ajax
. After lot of time I saw that you unset all predefined$_POST
items.The problem that files in
#attached
are not loaded when loading views via AJAX is easy to solve: Just removeajax_page_state
from the array with all items to remove. It is absolute okay to do that (I think) becauseajax_page_state
is never in$_GET
, only in$_POST
andajax_render
needs that.Comment #6
dawehnerSo that would still put the information into links, right? This feels like a major problem then.
Comment #7
yannickooSorry but what do you mean with
Comment #8
dawehnerSee
Comment #9
yannickooAh okay, got it! So it would be okay to just remove
ajax_page_state
from$_POST
? Is there a reason why we don't removejs
from the URL? Here is it:http://localhost/drupal/views/ajax?page=1&js=true
Comment #10
yannickooWhat do you think about this approach? Let me know if I should rewrite the comment.
Comment #11
Ayesh CreditAttribution: Ayesh commentedThanks for the patch. However, the above patch did fix the problem but it did not remove the data from pager and tablesort URLs.
The patch I'm attaching is for the current preventing Views from unsetting $_POST['ajax_page_state'], but it also removes key from $_GET at a later point, which Views use to build tablesort and pager URLs. We don't ajax_page_state data in URLs because misc/ajax.js takes care of them.
Comment #13
Ayesh CreditAttribution: Ayesh commentedWork it. Work it. Work it.
Comment #14
Ayesh CreditAttribution: Ayesh commentedComment #16
xumepadismal CreditAttribution: xumepadismal as a volunteer commentedHi guys!
I'm not sure whether my solution is a best way, but it works for me:
I think that all of that stuff is really unnecessary in $_GET and (maybe) $_REQUEST. However I don't see any reasons to cut it from $_POST. The only reason is the line
$_GET = $_POST + $_GET;
. So I created temporary variable and keep the original $_POST as is.About comment #4, I see what @merlinofchaos means so I've tested my patch a bit:
All the functionallity of that View was working fine for me.
Comment #17
xumepadismal CreditAttribution: xumepadismal as a volunteer commentedComment #18
xumepadismal CreditAttribution: xumepadismal as a volunteer commentedJust a re-roll…
Comment #19
spazfoxThe patch in #18 worked nicely for me, without breaking any other Views AJAX functionality (that I'm aware of, anyway).
Comment #20
zalak.addweb CreditAttribution: zalak.addweb commentedComment #21
riddhi.addweb CreditAttribution: riddhi.addweb at AddWeb Solution Pvt. Ltd. commentedComment #22
sumthief CreditAttribution: sumthief as a volunteer and at DrupalJedi commentedWorks good for me. But looks like it violate Drupal code standard (Comment string must end with a period).
I think that If someone'll re-roll this patch we can set RTBC to the issue.
Comment #23
julia.klimovsky CreditAttribution: julia.klimovsky at Sitrus Agency commentedReroll to the HEAD of 7.x-3.x
Comment #25
xumepadismal CreditAttribution: xumepadismal as a volunteer commentedFixes some coding standard violations (related to this patch only)
Comment #26
julia.klimovsky CreditAttribution: julia.klimovsky at Sitrus Agency commentedReroll to the HEAD of 7.x-3.x
Don't use this version. Use #27
Comment #27
julia.klimovsky CreditAttribution: julia.klimovsky at Sitrus Agency commentedSorry! Here is right one. Don't use #26.
Comment #28
MustangGB CreditAttribution: MustangGB commentedJust ran into the problem of new #attached's not being added during an AJAX request, patch works beautifully!
Comment #29
MustangGB CreditAttribution: MustangGB commentedThis patch has made me so happy, would be amazing to have this committed.
Comment #31
DamienMcKennaCommitted. Thank you.