Fixing the Enter submission on the List item entry view

This commit is contained in:
Brian McGonagill 2022-08-23 18:44:56 -05:00
parent fe8f56654b
commit 051d2eeabc
2 changed files with 17 additions and 7 deletions

View file

@ -30,5 +30,4 @@
{{/if}} {{/if}}
</div> </div>
</div> </div>
</template> </template>

View file

@ -51,12 +51,23 @@ Template.listItemsForm.events({
}); });
} }
}, },
'keypress #listItemInput' (event) { 'keydown #listItems' (event) {
event.preventDefault(); if (event.which === 13) {
let item = $("#listItems").val();
}, let listId = Session.get("listId");
'click .editListItem' (event) { if (item == null || item == "") {
event.preventDefault(); Session.set("itemReqErr", true);
} else {
Meteor.call("add.listItem", item, listId, function(err, result) {
if (err) {
console.log(" ERROR adding item to list: " + err);
} else {
console.log(" SUCCESS adding item to list.");
$("#listItems").val("");
}
});
}
}
}, },
'click #showReceivedItems' (event) { 'click #showReceivedItems' (event) {
if ($("#showReceivedItems").prop('checked') == true) { if ($("#showReceivedItems").prop('checked') == true) {