raty-fa icon indicating copy to clipboard operation
raty-fa copied to clipboard

feature dynamic scoreName

Open opan opened this issue 9 years ago • 1 comments

Hey Jacob, thanks for this great plugin. i want to ask if there's already feature like this? Because i just forked this repo, and make little change.

_createScore: function() {
      var scoreName = this.opt.scoreName;
      if (typeof scoreName === 'function'){
        scoreName = this.opt.scoreName();
      }
      return $('<input />', { type: 'hidden', name: scoreName }).appendTo(this);

i hope this maybe help someone. thank you

opan avatar May 20 '16 14:05 opan

Thanks for your comment!

I guess you could wrap the instantiation of Raty-fa in a function and supply the scoreName as needed. Your fork works, but it changes only one option. All the options are supposed to be static, so changing one option would only serve to confuse the option object.

Your functionality could of course be wrapped like this in a dynamic setting:

function createRaty(scoreName) {
    $('#score').raty({
        scoreName: scoreName
    });
}

It is also a possibility to reset the instance with a new option:

$('#score').raty('set', { scoreName: 'newName' });

What do you think?

iOvergaard avatar Sep 02 '16 13:09 iOvergaard