Working great at load, rateit() not working afterwards.

Feb 17, 2013 at 5:28 PM
Edited Feb 17, 2013 at 9:20 PM
Hi There,

Great plugin. I am using rateit in a custom wordpress theme, and am having a problem using the rateit() function.

I've created a number of rateit objects at load time like:
<div class="rateit" id="resRatingAverage" data-rateit-value="0" data-rateit-ispreset="true" data-rateit-readonly="true"></div>
This works great. However, when trying to do something like:
$('#resRatingAverage').rateit('value', 3);
I am getting: TypeError: Object [object Object] has no method 'rateit'

The same happens if I try to dynamicially create a start rating like:
This is strange as I know the function works, as the star ratings created at load time work perfectly. I've been able to get what I am trying to accomplish done in fiddles, and even via js console on your demo page. I'm hoping I am just missing something, but also fear there may be a conflict as this project has a lot of JS stuff I didn't write.

Any thoughts would be greatly appreciated.
Feb 17, 2013 at 9:20 PM
So that was frustrating....

As I got further in to debugging this, I found that jQuery was being very carelessly included, in different versions throughout this WP template. (I'm kind of mystified as to how all the other scripts weren't breaking, or that any jQuery worked at all with this arrangement.)

If anyone else runs into this problem (Using this or other jQuery plugins in wordpress themes or plugins), make sure and figure out where and how jQuery is being included.

When including jQuery and other libraries into WP, you should ONLY be using the wp_register_script(), and wp_enqueue_script() plugins.

You learn something new everyday. facepalm.

Fixed now and working great. Thanks again.
Feb 18, 2013 at 6:14 AM
I started reading your first post by mail, and the first thing that came to mind is that another jQuery is being loaded after RateIt was loaded.

I guess other scripts didn't break because they were called only once perhaps (their initializtion).

Great it works for you now.