sheadawson/silverstripe-rateable

Multiple instances of the same rating on the same page

sanderha opened this issue · 1 comments

First of all, great module!

Heres the things:
I've attached Rateable to "StoryPage", and the UI shows up fine when looping these pages out. However, if I loop the same Storypages, multiple places on the same pages, it breaks. This is because of the ID used in the injected JavaScript.

My hacky fix was to modify getRatingHTMLID() function to add a random number to the ID:

    public function getRatingHTMLID(){
        return $this->owner->ClassName . '-' . $this->owner->ID . '-' . 'rating-' . rand();
    }

Might need to figure out a better way to fix this

Thanks! See how you go with this solution