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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Just to quote the code:

    // Remove all of this stuff from $_GET so it doesn't end up in pagers and tablesort URLs.
ifux’s picture

okay, $_GET no problem, but why deleting it also from $_REQUEST and $_POST?!?
$_REQUEST maybe, but $_POST definitivly not!

dawehner’s picture

Feel free to make a patch and get people to test it.

merlinofchaos’s picture

Removing 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.

yannickoo’s picture

Status: Active » Needs review
FileSize
696 bytes

I'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 and sites/all/modules/contrib/field_group/field_group.js) are not loaded. I debugged in ajax_render, drupal_get_css and views_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 remove ajax_page_state from the array with all items to remove. It is absolute okay to do that (I think) because ajax_page_state is never in $_GET, only in $_POST and ajax_render needs that.

dawehner’s picture

So that would still put the information into links, right? This feels like a major problem then.

yannickoo’s picture

Sorry but what do you mean with

So that would still put the information into links, right?

dawehner’s picture

See

Remove all of this stuff from $_GET so it doesn't end up in pagers and tablesort URLs.

yannickoo’s picture

Ah okay, got it! So it would be okay to just remove ajax_page_state from $_POST? Is there a reason why we don't remove js from the URL? Here is it: http://localhost/drupal/views/ajax?page=1&js=true

yannickoo’s picture

What do you think about this approach? Let me know if I should rewrite the comment.

Ayesh’s picture

Thanks 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.

Status: Needs review » Needs work
Ayesh’s picture

Work it. Work it. Work it.

Ayesh’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
xumepadismal’s picture

Hi 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:

  • Page view, formatted as sortable table
  • Use AJAX: true
  • Exposed filters (one, taxonomy terms); Apply & reset buttons
  • Pager

All the functionallity of that View was working fine for me.

xumepadismal’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Status: Needs work » Needs review
xumepadismal’s picture

Just a re-roll…

spazfox’s picture

The patch in #18 worked nicely for me, without breaking any other Views AJAX functionality (that I'm aware of, anyway).

zalak.addweb’s picture

Issue tags: +views
riddhi.addweb’s picture

Issue tags: +Ajax, +quicktabs, +Fivestar
sumthief’s picture

Works 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.

julia.klimovsky’s picture

Reroll to the HEAD of 7.x-3.x

Status: Needs review » Needs work

The last submitted patch, 23: views-ajax_post_data-1869236-23.patch, failed testing.

xumepadismal’s picture

Fixes some coding standard violations (related to this patch only)

julia.klimovsky’s picture

Reroll to the HEAD of 7.x-3.x
Don't use this version. Use #27

julia.klimovsky’s picture

Sorry! Here is right one. Don't use #26.

MustangGB’s picture

Status: Needs review » Reviewed & tested by the community

Just ran into the problem of new #attached's not being added during an AJAX request, patch works beautifully!

MustangGB’s picture

This patch has made me so happy, would be amazing to have this committed.

  • DamienMcKenna committed c69ac04 on 7.x-3.x
    Issue #1869236 by xumepadismal, julia.klimovsky, yannickoo, Ayesh,...
DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -views

Committed. Thank you.

Status: Fixed » Closed (fixed)

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