Blockhelp

From rbachwiki
Revision as of 21:31, 17 January 2017 by Bacchas (talk | contribs) (Created page with "<pre> <script id="content" type="text/x-handlebars-template"> {{#makeRadio "size"}} small medium large {{/makeRadio}} </script> </pre> '''Javascript''' <pre> templateInfo = $(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
<script id="content" type="text/x-handlebars-template">
{{#makeRadio "size"}}
small
medium
large
{{/makeRadio}}
</script>

Javascript

templateInfo = $('#content').html();
template = Handlebars.compile(templateInfo);
Handlebars.registerHelper("makeRadio", function(name, options){
 var radioList = options.fn();
radioList = radioList.trip().split("\n");

var output = "";
for(var val in radioList){
 var item = radioList[val].trim();
output += '<input type="radio" name="'+ name + '"value="' + item + '">' + item + '<br />';
}
return output;
// create blank template data
var templateData = template({});
$('#content').html() = templateData;
})


Back To Top< — > Handlebars Category< — > Java Script Category<--> Home