Gefferey Zhang
Gefferey Zhang

Reputation: 95

jquery plugin callback to reset default option

my poor js drives me crazy. i used a jquery plugin called raty, which is a star rating plugin

i used it like this way

 $('span.sessionRating').raty({starOff: 'images/star-off.png', starOn: 'images/star-on.png', click: sessionRate});

 function sessionRate (score, evt) {
    $(this).raty ({readOnly:true});
}

the problem is $(this).raty ({readOnly:true}) will recreate the star rating again. so i am wondering how can we reset the option without recreating everything;

thanks. i have googled a lot, but found no answer!

Upvotes: 1

Views: 124

Answers (1)

Daniel J.G.
Daniel J.G.

Reputation: 35012

From the documentation:

$('div').raty('readOnly', boolean);      // Change the read-only state.

So you could try this:

function sessionRate (score, evt) {
    $(this).raty('readOnly', true);
}

Upvotes: 1

Related Questions