rateit with pagedlist.mvc unobtrusive-ajax

Apr 6, 2013 at 10:00 PM
I'm trying to use .on instead of .bind after an ajax call made with pagedlist.mvc but rateit never loads. Has anyone tried to do this? Once page updates via Ajax I don't get the stars showing.
<script type ="text/javascript"> $('.rateit').on('rated', function (e) { var ri = $(this); var value = ri.rateit('value'); var skillID = ri.data('productskillid'); // //maybe we want to disable voting? ri.rateit('readonly', true); $.ajax({ url: '/Controller/Action data: { id: skillID, value: value }, type: 'POST', error: function (jxhr, msg, err) { $('#skill').append('<p style="color:red">' + msg + '</p>'); } }); }); </script>
Apr 7, 2013 at 6:49 AM

Your binding is not correct, at the moment you bind it only to existing items on the page, in order for the binding to also work on dynamically added items to the page (in your case after the paging happened) you will have to change it to:
<script type ="text/javascript"> 
        $('body').on('rated', '.rateit', function (e) { 
            /// your code
You might want to change the selector from $('body') to something more specific, but which doesn't change, perhaps the container in which the pageable content sits.