Fivestar will accept and process a vote initially, the stars show up great, but when you ajax paginate to the next node result, fivestar is downgraded to a pulldown menu, and it errors out when you process the vote.

Running Views2 rc3 & VotingAPI rc1

I'm referring to the widget/field within the view/block using print $fields['value']->content;

I tried adding print fivestar_add_css() within the block, but that didn't help...

You can see it here

Any ideas?

#1 fivestar_behaviors.patch721 bytesquicksketch


quicksketch’s picture

Category: support » bug
Status: Active » Fixed
721 bytes

Hi Mike,

Fivestar needs to be switched to using Drupal 6 "behaviors" instead of only performing actions on page load as it does now. It's not actually the CSS that's missing, but the JavaScript functionality.

Fortunately this is a really easy change using the attached patch. I've also committed the change to the Drupal 6 branch. Note that due to the lack of a central repository in Drupal 5, a back port is not possible for the D5 version of the module.

virtualdrupal’s picture

Status: Fixed » Postponed (maintainer needs more info)

Thanks for the fast response, sounds like an easy fix but I must have failed somewhere... When I ran the patch using cygwin I got the following error ::

$ patch -p0 < fivestar_behaviors.patch

patching file fivestar.js
Hunk #1 FAILED at 367.
1 out of 1 hunk FAILED -- saving rejects to file fivestar.js.rej

copy of the rej is here

I was running it locally with the patch and the fivestar.js file within my /cywgin/home/local folder...

You mentioned it's been added to the Drupal 6 Branch, does that mean I can just grab the latest Dev of fivestar?

Best Regards and thanks again

quicksketch’s picture

Yep, you can just grab the nightly build from As 1.13 has no known problems and I've just made a large change to the development version (multi-axis rating), it'll probably be a little while before 1.14 comes out, but there's no harm running the development version.

virtualdrupal’s picture

I think that might not be the fix for mine, I updated to the latest dev and my javascript file reflects the change ( but the issue isn't solved...

quicksketch’s picture

Title: Ajax Pagination in Views2 breaks CSS » Ajax Pagination does not attach behaviors
Project: Fivestar » Views
Version: 6.x-1.x-dev » 6.x-2.x-dev
Assigned: Unassigned » quicksketch
Status: Postponed (maintainer needs more info) » Needs review

Heh, sheesh. Double-whammy. It looks like Views isn't properly attaching the behaviors now. The intention is there, but the logic is switched around.

The current lines that attach the behaviors are:

    var view = $(target).replaceWith(response.display).get(0);

Unfortunately, the "replaceWith" method returns the "target" DOM element, which has just been removed from the DOM, so there's nothing receiving the new behaviors.

To keep this a one-liner, we can use this bit of voodoo (sorry I couldn't find a way to keep it shorter and on a single line:

    var view = $(response.display).insertBefore(target).next().remove().end().get(0);

This makes it so that the "response.display" is the returned DOM element, and therefor receives the behaviors.

merlinofchaos’s picture

Status: Needs review » Closed (duplicate)
quicksketch’s picture

Title: Ajax Pagination does not attach behaviors » Ajax Pagination does not work with Fivestar
Project: Views » Fivestar
Version: 6.x-2.x-dev » 6.x-1.13
Status: Closed (duplicate) » Fixed

Thanks merlinofchaos! I'll move back into the Fivestar queue for anyone else having this problem.

virtualdrupal’s picture

That did the trick, thank you so much :bowdown:

I switched ajax_view.js to this

    var view = $(response.display).insertBefore(target).next().remove().end().get(0);

and all is well... (obviously I style have some styling issues to contend with, but I was waiting for this cure to tackle it) THANK YOU AGAIN, you guys really work fast.


Any clues on those fields I have "question marks" substituted for currently on just above the star widget, I've been searching the forums for a way of "ranking" the view results so that the descended sort result is ranked "#1" and so on down the line as you paginate, the closest I could find people talking about it is, but there was no answer...

I also wanted to replace the 2nd set of question marks with the number of votes, I know fivestar will tell you how many votes there were within the widget if you turn that part on, but I can't control where that number gets displayed as a separate field, it's tied to the widget... before you guys got fivestar working properly with views2 a couple of weeks ago it would tell you the number of votes and that's it (no working widget yet at that point), but now that it's fixed the only field options I see force the use of the widget, I've turned on every single field related to votingapi but none of them show the number of votes... (if you know what field it is and I just overlooked it, let me know)

Should I create a support request and keep this separate?

quicksketch’s picture

Yes, please open a new request. Otherwise the issues get all mixed up and it's impossible to find problems by browsing the queue or search.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

fliangz’s picture

Assigned: quicksketch » Unassigned
Status: Closed (fixed) » Closed (won't fix)

I have tried to follow the above instructions, but somehow it still doesn't work, where am i doing wrong ?

Currently, I have views 6.x-2.5 and fivestar 6.x-1.13 installed, the patch no.6 commited by merlinofchaos was already submitted into views 6x-2.5 since I have seen the "Drupal.attachBehaviors(view);" statement there.

So, I reckon my problem would lie on the /modules/fivestar/js/fivestar.js, then I downloaded the nightly build of fivestar from the following link, afterward replaced the fivestar.js. The only difference that I have noticed was:

Drupal.behaviors.fivestar = function(context) {
$('div.fivestar-form-item:not(.fivestar-processed)', context).addClass('fivestar-processed').rating();
$('input.fivestar-submit', context).css('display', 'none');

as previously mentioned by quicksketch. But, it still won't work, any hint guys ?

fliangz’s picture

Status: Closed (won't fix) » Fixed

my bad guys, clearing the cache works for me ... thanks :D

Macronomicus’s picture

For fixing this! What a relief!

Status: Fixed » Closed (fixed)

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

AntiNSA’s picture

Status: Closed (fixed) » Active

I am having the problem that 5 stars used in block with ajax pagination , stars works, voting works, but when clicking on second page in pager I get a white block where the block should be, ie nothing. This is a huge problem. page 1 works. Page 2 huge problem. P_lease help me with this. Im using chrome.

mrtbc’s picture

There still seems to be an issue with Fivestar and Ajax Views on page 2. Any chance of a fix please...

whiteph’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

We can no longer support the Drupal 6 version of Fivestar. It is in security maintenance mode only. When the Drupal 8 version of Fivestar is released, the Drupal 6 version will be officially deprecated.

whiteph’s picture