Flask-Web-App-Tutorial
Flask-Web-App-Tutorial copied to clipboard
home.html - Property assignment expected error
Could someone please help with the error I am getting with the home.html file?
There were 3 error, but I updated the code as I noticed that "note.id" wasn't being used anywhere else and I think it should have been "noteId" as defined in the index.js file in the static folder. Original code: <button type="button" class="close" onClick="deleteNote({{ note.id }})">
Updated to this and it cleared one of the "Property assignment" errors. <button type="button" class="close" onClick="deleteNote({{ noteId }})">
I am still getting these two errors: Property assignment expected. javascript [Ln9, Col64]
Here is the full code:
{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content %}
Notes
-
{% for note in user.notes %}
- {{ note.data }} {% endfor %}
Hmmm, my post didn't come out in the same way I typed it.
Original code:
<button type="button" class="close" onClick="deleteNote({{ note.id }})">
Updated to this and it cleared one of the "Property assignment" errors.
<button type="button" class="close" onClick="deleteNote({{ noteId }})">
Here is the full code: ` {% extends "base.html" %} {% block title %}Home{% endblock %} {% block content %}
Notes
-
{% for note in user.notes %}
- {{ note.data }} {% endfor %}
<!--Extends - inherits all attributes from the base.html template-->
{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content
%}
<h1 align="center">Notes</h1>
<ul class="list-group list-group-flush" id="notes">
{% for note in user.notes %}
<li class="list-group-item">
{{ note.data }}
<button type="button" class="close" onClick="deleteNote({{ noteId }})">
<span aria-hidden="true">×</span>
</button>
</li>
{% endfor %}
</ul>
<form method="POST">
<textarea name="note" id="note" class="form-control"></textarea>
<br />
<div align="center">
<button type="submit" class="btn btn-primary">Add Note</button>
</div>
</form>
{% endblock %}
Hello everybody I have the same problem the web is working except the delete notes button when clicked it does not delete the note can anyone help please
@Luluam Can you post the error you are getting please? We can then try and figure out what the problem is. Thanks. :)
My delete button does not delete the notes
Also, the db has been created in this constancy folder, not in my website folder, I don't know why when I created the db the configuration below did not work at all. I read about it and I found out that due to the new version of sqlalchemy the config below does not work anymore create_database(app)
def create_database(app): if not path.exists('website/' + DB_NAME): db.create_all(app=app) print('Created Database!') instead, I used the following configuration below Many thanks for the attention mate.
Try this it worked for me!
{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content %} <h1 align="center">Notes</h1> <ul class="list-group list-group-flush" id="notes"> {% for note in user.notes %} <li class="list-group-item"> {{ note.data }} <button type="button" class="close" onClick="deleteNote('{{ note.id }}')" <span aria-hidden="true">×</span> </button> </li> {% endfor %} </ul> <form method="POST"> <textarea name="note" id="note" class="form-control"></textarea> <br /> <div align="center"> <button type="submit" class="btn btn-primary">Add Note</button> </div> </form> {% endblock %}