0

Am using this Bootstap star rating plugin version v4.0.5 with JQuery 3.1.1. I have initialized the plugin after calling livequery plugin (from this author Brandon Aaron) as my star rating input is added on demand when the DOM is already initialized The whole thing works great with the only exception that events get called so many time. And the number of time they get triggered keeps increasing on the same element when the user interacts with. (See the image below)

Please, any idea on what could be the reason for this? Any fix?

My script:

$('.langLevel').livequery(function() {
  $('#langLevel0').rating({
    step: 1,
    min: 0,
    max: 5,
    size: 'sm',
    theme: 'krajee-fa',
    // clearButton: '',
    captionElement: "",
    showCaptionAsTitle: false,
    starCaptions: {
      1: 'Beginner',
      2: 'Intermediate',
      3: 'Advanced',
      4: 'Proficient',
      5: 'Native'
    },
    starCaptionClasses: {
      1: 'text-danger',
      2: 'text-warning',
      3: 'text-info',
      4: 'text-primary',
      5: 'text-success'
    }
  }).on("rating:clear", function(event) {
    console.info("Your rating is reset");
  }).on("rating:change", function(event, value, caption) {
    console.info("You rated: " + value + " = " + $(caption).text());
  });
}, function() {
  // unmatchFn
  return;
});

Thank you in advance for your assistance

Rohit Sharma
  • 3,304
  • 2
  • 19
  • 34
BoCyrill
  • 1,219
  • 16
  • 17
  • Can you provide a minimal code sample that recreates your problem. – James Hibbard May 01 '19 at 08:48
  • Minimal code is this: `$('.langLevel').livequery(function() { $('#langLevel0').rating({}).on("rating:clear", function(event) { console.info("Your rating is reset"); }).on("rating:change", function(event, value, caption) { console.info("You rated: " + value + " = " + $(caption).text()); }); }, function() { // unmatchFn return; });` – BoCyrill May 01 '19 at 10:56
  • Sorry, I meant something that we can run. For example in JSFiddle. https://stackoverflow.com/help/mcve – James Hibbard May 01 '19 at 14:01

0 Answers0