raty-fa
raty-fa copied to clipboard
feature dynamic scoreName
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
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?