rating set dynamically using Jquery

Jun 2, 2012 at 5:26 AM

<script type="text/javascript">
$(document).ready(function(){
 $("#rating").append('<div id="rating_sub" class="rateit" data-rateit-value="3.5" data-rateit-ispreset="true" data-rateit-readonly="true"></div>');

  });

 

This does not work as expected.Pls.advise.

Coordinator
Jun 2, 2012 at 8:39 AM

From first sight I would say you forgot to call rateit on the newly created element:

 

$("#rating").append('<div id="rating_sub" class="rateit" data-rateit-value="3.5" data-rateit-ispreset="true" data-rateit-readonly="true"></div>').rateit();

I this doesn't work out for you, please give me some info, like a link to the page, or a jsfiddle.

Jun 2, 2012 at 10:40 PM

How can I disable mouser over and mouse click events on the star?

Jun 3, 2012 at 4:54 AM
Edited Jun 3, 2012 at 4:55 AM

I am setting the value dynamically from Javascript using 

$("#rating").append('<div id="rating_sub" class="rateit" data-rateit-value="3.5" data-rateit-ispreset="true" data-rateit-readonly="true"></div>').rateit('value','4');

I want to diasble mouse over and mouse click events on the star for rating once it is set.

How can I achieve it?
Coordinator
Jun 3, 2012 at 7:48 AM

See http://www.radioactivethinking.com/rateit/example/example.htm#ex_11

You can make any rateit control readonly by doing: 

$(SELECTOR).rateit('readonly',true);