Please help!!! When rate-button clicked I need update not only score, but the whole widget.
Because after user clicks, widget must be a simple text.

Now my widget becomes inactive only after click and manually refreshing the entire page. I need some jquery tips but I'm novice...

Comments

mauritsl’s picture

Status: Active » Fixed

The widget HTML is always reloaded when clicking a button (even with AJAX).

You have to create your own widget template, where you do the following:

if (isset($results['user_vote'])) {
  print t('Thanks for your vote!');
}
else {
  // Original template here.
}

More information on how to create templates can be found in README.txt.

konon’s picture

Maurits, it works perfectly. Thank you very much!
Your tip + my code solves the problem in issue.
I used a custom (draft) template (if someone need too):

  $num = 0;
  foreach ($links as $link) {
    ++$num;
    if (isset($results['user_vote'])) { // if user already voted (after click)
      // show buttons as simple text
      print theme('rate_button', array('text' => $link['text'],  'class' => "rate-button"));
    }
    else {
      // else show buttons as links
      print theme('rate_button', array('text' => $link['text'], 'href' => $link['href'], 'class' => "rate-button-$num"));
    }
  }
  print $results['rating']; // total score

Status: Fixed » Closed (fixed)

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