Sorry, I haven’t used this component and don’t know what js plugin is used there.
I use Raty. As you can see, some event handlers can be added there. For example, if i have a grid of items, I can add data-score attribute and then use something like
<script>
$('[data-score]').raty({
path: '/js/raty/img', // custom images
width: 300,
score: function() {
return $(this).attr('data-score'); // function to calculate the initial score
},
click: function(score, evt) {
console.log('new score is ' + score); // onclick handler
}
});
</script>
In your case I suppose you can use something like $(’.star-selector’).on(‘change’, function() {…}).
Anyway, read the docs about js plugin you use, there can be a lot of useful stuff.
Next part is ajax request. You should use POST for it:
$.post('/url/to/ajax/action', {some: 'data'}, function() { console.log('succeed'); }
See JQuery docs for details.
So your client code can look like this (in pseudo-code):
$('.star-rating-selector').on('some-event', function(e) { $.post(...); }<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />;
The action for request processing is old plain action,
public function actionUpdateRating($item_id)
{
if (isset($_POST[...])) { ... update value }
}
just make sure you’re not calling render in it (in order to save traffic).
Ok, that was a lot of pseudo-code
Concrete implementation will heavily depend on your actual needs, but I think you got the idea.