Exposed filter in a block, autosubmit enabled, when selecting an option and new content loads in, it is wrapped in an additional div.

So at first it look like this:

<div class="content">
  <div class="view ...">...</div>
</div>

After several ajax loads:

<div class="content">
  <div>
    <div>
      <div>
        <div class="view ...">...</div>
      </div>
    </div>
  </div>
</div>
CommentFileSizeAuthor
#3 viewsblock.png194.07 KBvgulla
#2 views-ajax-divitis-1221980-2.patch275 bytestemaruk

Comments

temaruk’s picture

The response.data contains a space character at the end.

Taken from misc/ajax.js:

  // We don't know what response.data contains: it might be a string of text
    // without HTML, so don't rely on jQuery correctly iterpreting
    // $(response.data) as new HTML rather than a CSS selector. Also, if
    // response.data contains top-level text nodes, they get lost with either
    // $(response.data) or $('<div></div>').replaceWith(response.data).
    var new_content_wrapped = $('<div></div>').html(response.data);
    var new_content = new_content_wrapped.contents();

    // For legacy reasons, the effects processing code assumes that new_content
    // consists of a single top-level element. Also, it has not been
    // sufficiently tested whether attachBehaviors() can be successfully called
    // with a context object that includes top-level text nodes. However, to
    // give developers full control of the HTML appearing in the page, and to
    // enable Ajax content to be inserted in places where DIV elements are not
    // allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new
    // content satisfies the requirement of a single top-level element, and
    // only use the container DIV created above when it doesn't. For more
    // information, please see http://drupal.org/node/736066.
    if (new_content.length != 1 || new_content.get(0).nodeType != 1) {
      new_content = new_content_wrapped;
    }

So with the space character at the end, new_content_wrapped will contain:

<div><div class="view...">...</div> </div>

And because of this new_content_wrapped.contents() will have a length of 2, as it will contain a TextNode besides the top level ElementNode. The problem is in views-view.tpl.php:

diff --git a/theme/views-view.tpl.php b/theme/views-view.tpl.php
index 7372ed4..94393ee 100644
--- a/theme/views-view.tpl.php
+++ b/theme/views-view.tpl.php
@@ -86,4 +86,4 @@
     </div>
   <?php endif; ?>
 
-</div> <?php /* class view */ ?>
+</div><?php /* class view */ ?>
temaruk’s picture

Status: Active » Needs review
StatusFileSize
new275 bytes
vgulla’s picture

StatusFileSize
new194.07 KB

I am not sure if this is related. Here is my issue:
I hope someone can help me with this. I have spent too many hrs trying to find the issue. I have a view with exposed filters. I enabled Ajax on the block mode and included it on a page.

The block renders fine first time, but when I set some of the filters of the filters and click on search button, it seems as though the view gets rendered multiple times on the left and right column and totally messes up the page. Attached is a screenshot of what it looks like. See how the view is re-rendered on the right column

How can I fix this

-vasantha

dawehner’s picture

Status: Needs review » Fixed

Patch seems to make sense. So commited to 7.x-3.x

@vgulla
Posting on every issue witch has a similar title doesn't help :)

vgulla’s picture

Sorry for posting on multple ones. I was getting desperate and was not sure which one would be responded to. BTW, this patch http://drupal.org/files/issues/981870-safe-dom-id.patch worked for me.

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