Displaying a big AJAX response can cause Safari 3 and IE6 to fail: the former displays an empty view page (no result, just the title) the latter freezes.

I located the problem in ajax_view.js, line 27: the $(response.display) call fails and returns an empty result or (I suppose) just freezes.

I tried reducing the number of rows in the result and the view behaves correctly.

I found this workaround (ignore the PHP tags :)

<?php
    // ajax_view.js, line 27
    //var $newView = $(response.display);
    //$view.replaceWith($newView);
    $view.replaceWith(response.display);
    //$view = $newView;
?>

but I'm sure it's going to break something as it suppress the recently introduced $newView variable.

CommentFileSizeAuthor
#4 views-338938-4.patch658 bytesplach

Comments

SeanBannister’s picture

I'm experiencing the same problem

jwinton’s picture

Same issue with Safari 4 beta too.

dawehner’s picture

@Plach
Could you create a patch?

Anyone else having this problem? I cannot test on safari3 here.

plach’s picture

Status: Active » Needs review
StatusFileSize
new658 bytes

Here it is.

As I said before I ain't sure it won't break something, but the project where I deployed it has not been having problems for almost 1 year.

merlinofchaos’s picture

The problem with this patch is that behaviors will not run on the new code. replaceWith won't actually change the $view object, so the behaviors code does not work right in this case. This is a bit of a conundrum. I'm not sure how to fix this right.

markus_petrux’s picture

Trying to attach behaviors to the DOM element rather than the jQuery object?

-  Drupal.attachBehaviors($view.parent());
+  Drupal.attachBehaviors($view.parent().get(0));

I used this method in other scenarios, also after a replaceWith() operation, and it seems to work ok.

Another option would be passing the document. If behaviors are well coded, they won't do anything to elements that have already been processed (using the 'processed' class to flag elements already processed), so I think passing the document could also be a valid approach. In that case, the change would look like this:

-  Drupal.attachBehaviors($view.parent());
+  Drupal.attachBehaviors(document);
merlinofchaos’s picture

As time has gone on, it's probably better to just attach behaviors to the document anyway. There are proven examples where it's problematic not to.

Let's get a patch rerolled that way, please?

esmerel’s picture

Status: Needs review » Needs work

Changing to 'needs work' because merlinofchaos has requested a new patch; if there isn't one in 90ish days, the issue will be changed to "Won't fix"

dooug’s picture

Subscribing

I experienced some similar issues recently and the above patch solved the problem.

jenlampton’s picture

Status: Needs work » Closed (won't fix)

Changing to won't fix due to lack of activity.