我有一个项目清单,我想增加投票的能力或下降。我不知道怎么设计这个。
我应该让选票成为一个表,并提供更多关于投票的信息,比如voted?
发布于 2011-09-30 20:35:26
不知道为什么你被否决了-对我来说是个好问题.
不管怎么说,我建议存储谁和总票数一起投票--它会让你阻止人们投票多少次,这是你不能只用投票总数就能做到的。
假设单击以进行投票的链接在其应用的LI中,则可以使用jQuery's success callback,并且$(this)将引用被单击的链接来查找您想要的LI:
$('a.vote').click(function() {
//Save the value of $(this) -
//I'm not positive it'll be the same in the callback:
var clicked_link = $(this);
jQuery.ajax({
// some options
success: function(data, status, xhr) {
var li = clicked_link.closest('li.votable');
//update the vote count from `data`
},
//some other options
});
});希望这能有所帮助!
https://stackoverflow.com/questions/7615543
复制相似问题