Looking for assistance with my Meteor app. I currently have a functionality to list names and numbers, insert and delete them. Now, I want to add a button to change either the name or number field. How can I achieve this in Meteor?
Below is a snippet of my code:
.html
<head>
<title>Meteor_CRUD</title>
</head>
<body>
{{> index}}
</body>
<template name="index">
<h1>List</h1>
<table>
<thead>
<td>Name</td>
<td>Number</td>
</thead>
<tbody>
<tr>
<td><input class="name" type="text"/></td>
<td><input class="number" type="text"/></td>
<td><button class="add">add</button></td>
</tr>
{{#each list}}
<tr>
<td>{{name}}</td>
<td>{{number}}</td>
<td><button class="del">del</button></td>
<td><button class="change">change</button></td>
</tr>
{{/each}}
</tbody>
</table>
.js
List = new Meteor.Collection("list");
if (Meteor.isClient) {
Template.index.helpers({
list : function () {
return List.find();
}
});
Template.index.events({
'click .del' : function (evt, tmpl) {
List.remove(this._id);
},
'click .add' : function (evt, tmpl) {
var name = tmpl.find(".name").value;
var number = tmpl.find(".number").value;
List.insert({name: name, number: number});
tmpl.find(".name").value = '';
tmpl.find(".number").value = '';
},
'click .change' : function (evt, tmpl) {
//List.update(this._id);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
Need some help with this task!
Thank you!