I am trying to implement a star rating system. I cant seem to get the results to update 1 label to the item itself. But I can get it to update an id and append it to a list but i dont want that. I need to create a singe id selector for each label so
it will update just 1 place when the rating is pressed.
$(document).ready(function () {
//we bind only to the rateit controls within the products div//$('#products .rateit').bind('rated reset', function (e) {
$(".rateit").bind('over', function (event, value) { $(this).attr('title', value); });
$(" .rateit").bind('rated reset', function (e) {
var ri = $(this);
//if the use pressed reset, it will get value: 0 (to be compatible with the HTML range control), we could check if e.type == 'reset', and then set the value to null .var value = ri.rateit('value');
var ratingid = ri.data('ratingid');
//maybe we want to disable voting?
ri.rateit('readonly', true);
$.ajax({
url: '/Home/GetRating', //your server side script
data: { id: ratingid, value: value }, //our data
type: 'POST',
success: function (data) {
$('#ratemsg').html(data);
},
error: function (jxhr, msg, err) {
$('#response').append('<li style="color:red">' + msg + '</li>');
}
});
});
});
</script>
@foreach (var item in Model)
{
<divid="TwitterMessageBox@(item.StatusId.ToString())"class="TwitterMessageBox">@* @MvcHtmlString.Create(@Html.TweetMessageid(@item.StatusId))*@<ol><liclass="TweetLineBody">@Html.Hidden("Statusid", item.StatusId)
<divclass="TwitProfileImage"><imgsrc=@Url.Content(item.ImageUrl) alt="@item.ScreenName"/></div><divclass="TwitRealName">@item.User
</div><divclass="TwitNickName">@MvcHtmlString.Create(@Html.Namify(@item.ScreenName))
</div><divclass="TweetText">@MvcHtmlString.Create(@item.Tweet)</div><divclass="TweetTime">@Html.RelativeDate(@item.Created)</div><divid="TweetMessageRating@(item.StatusId.ToString())"name="TweetMessageRating@(item.StatusId.ToString())"class="TweetRating">
// This is where the rating widget goes and records and updates
<divdata-ratingid="@item.StatusId"class="rateit"></div> // this is where i want to go but i cant figure out a way <spanid="ratemsg"name="TweetRating@(item.StatusId.ToString())"class="ratemsg"></span></div></li></ol></div>
}
mbhahn
Member
169 Points
119 Posts
Trying to Make selectors for a label from a repeater
Apr 13, 2012 10:25 PM|LINK
I am trying to implement a star rating system. I cant seem to get the results to update 1 label to the item itself. But I can get it to update an id and append it to a list but i dont want that. I need to create a singe id selector for each label so it will update just 1 place when the rating is pressed.
Song-Tian - ...
All-Star
43699 Points
4304 Posts
Microsoft
Re: Trying to Make selectors for a label from a repeater
Apr 16, 2012 06:34 AM|LINK
Hi,
Maybe you could use Ajax Control Toolkit Rating, more details, please refer to: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Rating/Rating.aspx and http://www.asp.net/ajaxlibrary/act_Rating.ashx.
Feedback to us
Develop and promote your apps in Windows Store
mbhahn
Member
169 Points
119 Posts
Re: Trying to Make selectors for a label from a repeater
Apr 16, 2012 02:16 PM|LINK
Im using mvc. I got my answer. I had to use ri.next to set the value of the next selector