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 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 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.jsandsites/all/modules/contrib/field_group/field_group.js) are not loaded. I debugged inajax_render,drupal_get_cssandviews_ajax. After lot of time I saw that you unset all predefined$_POSTitems.The problem that files in
#attachedare not loaded when loading views via AJAX is easy to solve: Just removeajax_page_statefrom the array with all items to remove. It is absolute okay to do that (I think) becauseajax_page_stateis never in$_GET, only in$_POSTandajax_renderneeds 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_statefrom$_POST? Is there a reason why we don't removejsfrom the URL? Here is it:http://localhost/drupal/views/ajax?page=1&js=trueComment #10
yannickooWhat do you think about this approach? Let me know if I should rewrite the comment.
Comment #11
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 commentedWork it. Work it. Work it.
Comment #14
ayesh commentedComment #16
xumepadismal 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 commentedComment #18
xumepadismal 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 commentedComment #21
riddhi.addweb commentedComment #22
sumthief 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 commentedReroll to the HEAD of 7.x-3.x
Comment #25
xumepadismal commentedFixes some coding standard violations (related to this patch only)
Comment #26
julia.klimovsky commentedReroll to the HEAD of 7.x-3.x
Don't use this version. Use #27
Comment #27
julia.klimovsky commentedSorry! Here is right one. Don't use #26.
Comment #28
mustanggb commentedJust ran into the problem of new #attached's not being added during an AJAX request, patch works beautifully!
Comment #29
mustanggb commentedThis patch has made me so happy, would be amazing to have this committed.
Comment #31
damienmckennaCommitted. Thank you.