demo: disable remove button when no selection

This commit is contained in:
Geoff Schmidt
2012-08-10 03:38:06 -07:00
parent eff18190b0
commit bc8aadff7c
2 changed files with 9 additions and 2 deletions

View File

@@ -180,8 +180,10 @@ Template.circles.events = {
},
'click .remove': function () {
var selected = Session.get("selectedCircle:" + this.group);
if (selected)
if (selected) {
Circles.remove(selected);
Session.set("selectedCircle:" + this.group, null);
}
},
'click .scram': function () {
Circles.find({group: this.group}).forEach(function (r) {
@@ -207,6 +209,11 @@ Template.circles.count = function () {
return Circles.find({group: this.group}).count();
};
Template.circles.disabled = function () {
return Session.get("selectedCircle:" + this.group) ?
'' : 'disabled="disabled"';
};
Template.circles.render = function (template) {
var self = this;
self.node = template.find("svg");

View File

@@ -81,7 +81,7 @@
<br>
{{count}} circles<br>
<input type="button" value="Add" class="add">
<input type="button" value="Remove" class="remove">
<input type="button" value="Remove" class="remove" {{{disabled}}}>
<input type="button" value="Scram" class="scram">
</div>
</template>