Skip to content

Commit bd2111a

Browse files
committed
update to new ractive edge and use delegated event
1 parent 221b290 commit bd2111a

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

ractive-edge/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"webpack": "1.13.1"
2424
},
2525
"dependencies": {
26-
"ractive": "ractivejs/ractive#edge"
26+
"ractive": "edge"
2727
}
2828
}

ractive-edge/src/main.es6.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,18 @@ var ractive = window.r = new Ractive({
132132
this.set("selected", id);
133133
stopMeasure();
134134
},
135+
clicked(ev) {
136+
var el = ev.original.target;
137+
var info = this.getNodeInfo(el);
138+
if (el.classList.contains('glyphicon-remove')) {
139+
this.remove(info.get('@index'));
140+
} else {
141+
this.select(info.get('.id'));
142+
}
143+
},
135144
el: "#main",
136-
template:
137-
`<div class="jumbotron">
145+
template:`
146+
<div class="jumbotron">
138147
<div class="row">
139148
<div class="col-md-6">
140149
<h1>Ractive edge</h1>
@@ -159,27 +168,26 @@ var ractive = window.r = new Ractive({
159168
<div class="col-sm-6 smallpad">
160169
<button type="button" class="btn btn-primary btn-block" id="swaprows" on-click="swapRows">Swap Rows</button>
161170
</div>
162-
</div>
171+
</div>
163172
</div>
164173
</div>
165174
</div>
166-
<table class="table table-hover table-striped test-data">
175+
<table class="table table-hover table-striped test-data" on-click="@this.clicked(event)">
167176
<tbody>
168-
{{#each store.data:num}}
177+
{{#each store.data}}
169178
<tr class-danger="{{~/selected === .id}}">
170179
<td class="col-md-1">{{.id}}</td>
171180
<td class="col-md-4">
172-
<a on-click="@this.select(.id)">{{label}}</a>
181+
<a>{{label}}</a>
173182
</td>
174-
<td class="col-md-1"><a on-click="@this.remove(num)"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
183+
<td class="col-md-1"><a><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
175184
<td class="col-md-6"></td>
176185
</tr>
177186
{{/each}}
178187
</tbody>
179188
</table>
180189
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
181-
`
182-
,
190+
`,
183191
data: { store: store, selected: undefined}
184192
});
185193

0 commit comments

Comments
 (0)