In a handlebars template, how do you set a radio button group to the right value using only the template? Can this be done directly in the template?
For an example,
My own solution is:
helper:
Handlebars.registerHelper ("setRadio", function (value, options) {
var $el = $(options.fn(this));
if ( value == $el.val() ) {
return $el.attr("checked", "checked")[0].outerHTML;
} else {
return options.fn(this);
}
Usage in template:
{{#setRadio stars}}{{/setRadio}}
{{#setRadio stars}}{{/setRadio}}
{{#setRadio stars}}{{/setRadio}}
{{#setRadio stars}}{{/setRadio}}
{{#setRadio stars}}{{/setRadio}}