If I put Poll block into a panel, reload of HTML stops working. Problem is, because js code searches for poll wrapper by class ".content", which is not there if located in a Panel.

Comments

quicksketch’s picture

Status: Active » Postponed

Hm, I'm open to patches but I don't use panels.

davidkronfeld’s picture

had the same issue for poll inserted on page as block (not in panel): the form is not wrapped into class '.content'.

I solved it (drupal 6.19 and ajax_poll 1.1) by adding the following code in the function ajax_poll_form_alter:

if ($block) {
    	$form['#prefix'] = '<div class="content">';
    	$form['#suffix'] = '</div>';
	}

the code will wrap the form into the required class.

sorry for not supplying the solution as patch - have no clue how to build it...

hope it helps though

David

quicksketch’s picture

That's an interesting solution David, but unfortunately won't work in all situations, like when working with the "Cancel vote" button, since it only wraps around the button and not the set of results. This probably isn't too big a problem since the Cancel button isn't usually displayed in blocks, but would be a problem if it were added.

A more direct route is ensuring that a "content" class is in your theme's block.tpl.php file. Just open it up and add an extra wrapper div around the contents of the block. See block.tpl.php in /modules/system/block.tpl.php or the default template provided by the Garland theme. Both include these wrappers.

The default block.tpl.php file provided by system module:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="block block-<?php print $block->module ?>">
<?php if ($block->subject): ?>
  <h2><?php print $block->subject ?></h2>
<?php endif;?>

  <div class="content">
    <?php print $block->content ?>
  </div>
</div>
paranojik’s picture

StatusFileSize
new2.53 KB

This patch ensures that the poll is wrapped in a known element.

paranojik’s picture

Status: Postponed » Needs review

Might need review...

quicksketch’s picture

Status: Needs review » Needs work

This patch is incomplete, as it will only work on forms, not on display of results (if the user is authenticated for example). It also doesn't work on the cancel form. This is generally a problem with the Poll module in that it has terrible default theming that makes it impossible to get a consistent wrapper. I honestly don't think there's a good solution here (other than to eventually fix the poll module).

dddave’s picture

sub :(

q11q11’s picture

Thou it searches first '.content' of all perents - I just added '.content' class in settings of pane itself

raulmuroc’s picture

Status: Needs work » Active

No patch is attached so 'Active'.

This problem affects to the rest of fields as well. For example, I have fields owned by a profile2 entity content type, and showed through panels. Their refresh/reload doesn't work at all. So the same problem as the one exposed here.

Tunox’s picture

I had a similar issue.
When clicking the vote button, poll wouldn't reload although the vote was taken into account. I had the poll block in different areas content, sidebar, pane.
As stated above adding a .content class (to the block in my case) did the trick.
I didn't consider this solution at first, because my Zen subtheme has an content div in it, but it was an ID #content and not .content. Double checking always helps.

Although this worked out for me, I'm really disappointed with the faulty design of the drupal's poll module. Conditioning module function logic to design elements that are bound to change it's simply not "proper".

jhedstrom’s picture

Status: Active » Needs review
StatusFileSize
new1.95 KB

The patch from #4 resolves this issue, and I'm not seeing any of the incompleteness mentioned in #6 (cancel button works, the display still works for users that cannot vote).

Patch from #4 rerolled without the CVS tags.

prashant.c’s picture

At first when we use ajax poll with panels it takes the vote but displays the result on a page refresh. After applying this patch submitted by #4 and re-rolled by #11 ajax poll works but doesn't display system status messages like "Your vote was recorded" etc. Because ".content" class is missing. I added this class to that particular poll pane in panels, status messages started working but now the issue is that after voting or cancelling the vote heading of the poll i.e. "Poll" disappears.

lsolesen’s picture

Status: Needs review » Needs work
StatusFileSize
new25.93 KB

When applying the patch the reload gets correct. However, the links are multiplied.

So there are #12 and #13 issues outstanding before this should be committed.

sgdev’s picture

I'm using Panels, and should work correctly if you use the patch that already has been reviewed and accepted here: https://www.drupal.org/project/ajax_poll/issues/1240768

It is essentially trying to do the same thing (create a "wrapper" for the form), but in a slightly different manner. I don't think this patch is needed if #1240768 is committed.