Skip to content

Added empty string check #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions content/docs/en/getting-started/2-playground-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ Use a `<ListView>` to show tasks below the input field.
* Replace the `countries`-related binding with a binding to your array of active tasks.
* In the `<script>` block, remove the array of countries and create an empty array for your active tasks.
1. In the `<scripts>` block, tie some logic to the tapping of the button.
* Check if the input is an empty string.
* Log newly added tasks in the console.
* Add newly added tasks into the array of active tasks. Use `unshift` to place new items at the top of the page.
* Clear the text field after input.
Expand Down Expand Up @@ -279,6 +280,7 @@ export default {
},

onButtonTap() {
if (this.textFieldValue === "") return; // Prevents users from entering an empty string.
console.log("New task added: " + this.textFieldValue + "."); // Logs the newly added task in the console for debugging.
this.todos.unshift({ name: this.textFieldValue }); // Adds tasks in the ToDo array. Newly added tasks are immediately shown on the screen.
this.textFieldValue = ""; // Clears the text field so that users can start adding new tasks immediately.
Expand Down Expand Up @@ -420,6 +422,7 @@ export default {
},

onButtonTap() {
if (this.textFieldValue === "") return; // Prevents users from entering an empty string.
console.log("New task added: " + this.textFieldValue + "."); // Logs the newly added task in the console for debugging.
this.todos.unshift({
name: this.textFieldValue
Expand Down Expand Up @@ -569,6 +572,7 @@ export default {
},

onButtonTap() {
if (this.textFieldValue === "") return; // Prevents users from entering an empty string.
console.log("New task added: " + this.textFieldValue + "."); // Logs the newly added task in the console for debugging.
this.todos.unshift({
name: this.textFieldValue
Expand Down