This is the checkboxes i have so far. I would like to have at least one checkbox checked all the time - how can this be accomplished?
HTML:
<form>
<ul>
{{#each checkbox}}
<li>
<input type="checkbox" checked="{{checked}}" class="toggle-checked"> {{name}}: {{checked}}
</li>
{{/each}}
</ul>
</form>
JS:
Cbtest = new Mongo.Collection('cbtest');
Template.checkbox.helpers({
checkbox: function () {
return Cbtest.find();
}
});
Template.checkbox.events({
"click .toggle-checked": function () {
var self = this;
Meteor.call("setChecked", self._id, !self.checked);
}
});
Meteor.methods({
setChecked: function (checkboxId, setChecked) {
Cbtest.update(checkboxId, {
$set: {
checked: setChecked
}
});
}
});
I'd like to avoid jquery and stick with javascript and underscorejs solely.
Thanks in advance! Vin
Aucun commentaire:
Enregistrer un commentaire