The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Need help with asynchronous vote system

Go down

In progress Need help with asynchronous vote system

Post by psybertech on 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

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 on 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
avatar
Ange Tuteur
Forumaster

Male Posts : 13187
Reputation : 2895
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

Back to top


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