Welcome Guest, Not a member yet? Register   Sign In
how to associate star rating system with a link
#1

[eluser]oursteps[/eluser]
I am trying to integrate star rating plugin(http://www.fyneworks.com/jquery/star-rating/) with my code.

for example:
Code:
$(function() {
       $('.auto-submit-star').rating({
            required: true,
            callback: function(value, link) {

            $.ajax({
                     type: "post",
                     url: site_url + "user/view/star",
                     dataType: "json",
                     data: "&video;=" + $('#video_url').val() + "&rate;_val=" + value,

              success: function(e) {
                   $.jGrowl(e.code + "<br>" + e.msg);
               }
         });
     }
});

But I don't understand what the parameter "link" is?

how can I associate the script with an item to be rated? (i.e. the system need to know which item is being rated...)

anyone can help me?

Thanks.
#2

[eluser]CroNiX[/eluser]
I believe link is the actual anchor that was clicked on. As far as associating the script with an item, I'd put it in the elements id, then when you click on it grab the ID and send it with the ajax.
#3

[eluser]oursteps[/eluser]
Thanks CroNIX.

I tried it like this:
Code:
[removed]
$(function(){
$('.auto-submit-star').rating({
  callback: function(value, link){
  var abc = $(this).parent().siblings("#vedio_url").text();...

and the HTML:
Code:
&lt;?php $i=1; if(isset($records)) : foreach($records as $row) : ?&gt;
<tr>
<td id="vedio_url">&lt;?php echo $row->url; ?&gt;</td>
<td>&lt;?php echo $row->sitename; ?&gt;</td>
<td>&lt;?php echo $row->tag; ?&gt;</td>
<td>
   &lt;input class="auto-submit-star" type="radio" name="rating&lt;?php echo $i;?&gt;" value="1"/&gt;
   &lt;input class="auto-submit-star" type="radio" name="rating&lt;?php echo $i;?&gt;" value="2"/&gt;
   &lt;input class="auto-submit-star" type="radio" name="rating&lt;?php echo $i;?&gt;" value="3"/&gt;
   &lt;input class="auto-submit-star" type="radio" name="rating&lt;?php echo $i;?&gt;" value="4"/&gt;
   &lt;input class="auto-submit-star" type="radio" name="rating&lt;?php echo $i;?&gt;" value="5"/&gt;
</td>
</tr>

It works now Smile




Theme © iAndrew 2016 - Forum software by © MyBB