Need help with asynchronous vote system
2 posters
Page 1 of 1
Need help with asynchronous vote system
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
Re: Need help with asynchronous vote system
Hi @psybertech,
Give the following script a try.
Placement : In the topics
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.
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.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum