vendredi 27 février 2015

ember.js check all checkboxes

Hi im learning ember and got stuck with checkboxes.


Heres my template (part):



<table>
<thead>
<tr>
<th class="cell-delete">
{{input type="checkbox" id=colorId name=colorId class="js-custom-checkbox" checked=allChecked}}



</th>
<th class="cell-star">
&nbsp;
</th>
<th class="cell-broadcaster">Author</th>
<th class="cell-title">Title</th>
<th class="cell-date">Date</th>
</tr>
</thead>
<tbody>

{{#each message in model.entities}}

<tr>
<td class="cell-delete">

{{input type="checkbox" id=trash name="trash[]" tabindex= message.id class="js-custom-checkbox check1" }}

</td>
<td class="cell-star">
{{input type="checkbox" name=message.id tabindex=message.id class="starBox" }}

</td>
<td class="cell-broadcaster">
{{message.notification.autor.firstName}} {{message.notification.autor.lastName}}
</td>
<td class="cell-title">
{{#link-to 'notifications.details' message.notification.id}}{{message.notification.title}}{{/link-to}} {{#unless message.isRead}} (new) {{/unless}}
</td>
<td class="cell-date">
{{formatDateWithDistance message.notification.cdate}}
</td>
</tr>

{{/each}}

</tbody>
</table>


And my question is how to enable action to check all checkboxes in this template?


Data for this are taken in router form json api:



export default Ember.Route.extend(AuthenticatedRouteMixin, {

model: function() {
return $.getJSON(ENV.apiHost + "/api/notificationdata/user/all");

},
.....




Aucun commentaire:

Enregistrer un commentaire