Fivestar module: auto refresh after vote

drupal tags: single modules   Fivestar   reload  

Fivestar is a little contributed Drupal module that allows you to cast a vote on any content type. I prefer it to other rating modules because it's simple and elegant, and it can be skinned to your likes easily as well.

In a website i developed i needed to automatically load another node once a vote was assigned. To obtain this, i setted a random view as the homepage, and inserted a javascript call in the page's template (page.tpl.php).

This way, every time a vote is casted with Fivestar, the homepage reloads automatically giving back the next random node.

The javascript call code i used is the following:

<script type="text/javascript">
function fivestarResult(voteResult) {
$('div#fivestar-summary-'+voteResult.vote.id).html(voteResult.result.summary);
window.location = "http://www.myhomepage.com/";
};
</script>

Do you know a better or more elegant way to obtain the same result? Let me know in the comments ;)


Similar:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <p> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <img> <hr>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Archives

February 2012
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
26272829
PureDivs Drupal Themes Conversions
PureDivs Conversione Temi Drupal