1
votes

I'm using the jquery star rating plugin: http://www.fyneworks.com/jquery/star-rating/

I might get some html code like this:

<form name="api-disable">
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="1"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="2"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="3"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="4"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="5"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="6"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="7"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="8"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="9"/>
  <input type="radio" class="star {split:2}" name="api-readonly-test" value="10"/>
  <input type="button" value="Submit &raquo;" onClick="
   $(this).next().html( $(this.form).serialize() || '(nothing submitted)' );
  "/>
  <span></span>
 </form>

This works fine, but if I try to call my own function my function doesn't alert. For example:

$('.star').click( function () {
    alert('test');
});

I also tried attaching an id and making that the click function, but still no luck. If I remove the star class from the buttons then my function will work. So it seems some of the code in this plugin prevents outer functions? What would I need to do to call my own function?

1

1 Answers

1
votes

The documentation suggests you can add a click callback, as well as some other events, when you activate that plugin:

$('.auto-submit-star').rating({ 
  callback: function(value, link){ 
   alert(value); 
  } 
});