Well, how to create picture link like this up or down votes (on the left) from link below? (ajax enabled link)
<%= Ajax.ActionLink("Vote!",
"AddPictureVote",
"Vote",
new {id = Model.PictureId},
new AjaxOptions{UpdateTargetId = "addvote"})%>
I think this is the basic idea. You can fill in the details/adapt as needed to your markup and model/actions.
$('.upvote').click( function() {
$(this).addClass('highlight');
$(this).nextAll('.downvote:first').removeClass('highlight');
$.post( '<%= Url.Action( "vote", new { id = Model.ID } %>', { vote: 'up' } );
});
$('.downvote').click( function() {
$(this).addClass('highlight');
$(this).prevAll('.upvote:first').removeClass('highlight');
$.post( '<%= Url.Action( "vote", new { id = Model.ID } %>', { vote: 'down' } );
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With