Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

feature dynamic scoreName #5

Open
opan opened this issue May 20, 2016 · 1 comment
Open

feature dynamic scoreName #5

opan opened this issue May 20, 2016 · 1 comment

Comments

@opan
Copy link

opan commented May 20, 2016

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

@iOvergaard
Copy link
Owner

iOvergaard commented Sep 2, 2016

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants