Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Checking radio with Mustache
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/mustache.js"></script>
<div id="formWrapper">
<script id="tmpl" type="x-template">
<label><input type="radio" name="gender" value="male"> Male</label>
<label><input type="radio" name="gender" value="female"> Female</label>
<script type="text/javascript">
var data = {
gender: 'female',
wrapped:function () {
return function (text) {
return text.replace('value="' + this.gender+'"', 'value="' + this.gender+'" checked');
var template = $("#tmpl").html();
var result = Mustache.render(template, data);

This comment has been minimized.

Copy link

bobthecow commented Mar 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.