Search code examples
jquerytwitter-bootstrapraty

Raty not working in bootstrap popover


I've added raty in bootstrap popover. It is not working in bootstrap popover windows but outside it works. Here is a js fiddle. Am I missing something? Thanks

Here is a rating code. Inside popover I am not able to click on ratings.

$('.ratings').raty({
    click: function(score, evt) {
        alert(score);
    }
 });

Solution

  • Since you are changing the DOM when clicking the "Hover Me" link it is likely you will need to reload the jQuery.raty plugin. Doesnt seem like they have any built in function to deal with that so the solution I found was to just call the same stuff again. Also note that you wrote "Hover" when the user has to actually "Click" to see the popup. You can find my fiddle here and the small code update is below.

    $('.link-container a').popover({
        content : function() {
            return $(this).siblings('.popover-content').html();
        }
    }).click(function(e) {
        e.preventDefault();  //not sure this is necessary
        $('.ratings').raty({
            click: function(score, evt) {
                alert(score);
            }
        });
    });
    
    $('.ratings').raty({
        click: function(score, evt) {
            alert(score);
        }
    });