The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Need help with asynchronous vote system

2 posters

Go down

In progress Need help with asynchronous vote system

Post by psybertech January 21st 2016, 7:13 pm

Technical Details


Forum version : #phpBB3
Position : Founder
Concerned browser(s) : Google Chrome
Who the problem concerns : All members
Forum link : ( link is hidden, you must reply to see )

Description of problem

Hi there.

I have read the following topic, "Improve the reputation system so it counts votes", and it achieves the end goal of clicking a vote plus icon to register the vote without leaving the page. That is great, but this tutorial also completely replaces the stock, default +/- on the far right of the posts with new like and un-like thumb icons at the top of the topic. Although it works great, I do not like this method for our forums and would love it for the default system.

Improve the reputation system so it counts votes

So I am looking for help to do the asynchronous up voting using the stock phpbb3 prosilver template.

I've looked at the code and tried a few things, but can't get it to work, so I am hoping someone out here can maybe help modify the above tutorial.

Any and all help would be greatly appreciated!

Thank you very much!
Jay
psybertech
avatar
psybertech
New Member

Posts : 6
Reputation : 1
Language : English

http://psybertech.forumotion.com

Back to top Go down

In progress Re: Need help with asynchronous vote system

Post by Ange Tuteur January 21st 2016, 8:11 pm

Hi @psybertech,

Give the following script a try.

Placement : In the topics
Code:
$(function() {
  // loop positive and negative vote anchors
  for (var a = $('.vote-button a'), i = 0, j = a.length; i < j; i++) {
   
    // bind function to click event
    a[i].onclick = function() {
      var t = this, // clicked anchor
          vote = $(t).closest('.vote'), // current vote actions
          pid = t.href.replace(/.*?p_vote=(\d+)$/, '$1'); // voted post id

      // get and submit the vote
      $.get(t.href, function() {

        // get the curent page
        $.get(window.location.href, function(d) {

          // update the vote actions with the new vote bar
          vote.html($('#p' + pid + ' .vote', d).html());
         
        });

      });

      // unbind click and empty href attribute on the vote anchors
      $('a', vote).off('click').attr('href', '#');

      return false;
    };

  }
  // par ange tuteur
});

It should make the default reputation buttons asynchronous, although two requests are submitted to the server ; 1 to get and submit the vote, and 1 to get the updated vote actions. If any problems or questions let me know. Wink
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum