Flask-Web-App-Tutorial icon indicating copy to clipboard operation
Flask-Web-App-Tutorial copied to clipboard

home.html - Property assignment expected error

Open nadeembu opened this issue 2 years ago • 8 comments

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 %}

{% endblock %}

nadeembu avatar Oct 29 '22 01:10 nadeembu

Hmmm, my post didn't come out in the same way I typed it.

nadeembu avatar Oct 29 '22 01:10 nadeembu

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 %}

{% endblock %}`

nadeembu avatar Oct 29 '22 01:10 nadeembu

<!--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">&times;</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 %}

nadeembu avatar Oct 29 '22 01:10 nadeembu

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 avatar Dec 04 '22 23:12 Luluam

@Luluam Can you post the error you are getting please? We can then try and figure out what the problem is. Thanks. :)

nadeembu avatar Dec 05 '22 07:12 nadeembu

My delete button does not delete the notes

Screenshot (7) Screenshot (8) Screenshot (9) Screenshot (10)

Luluam avatar Dec 06 '22 00:12 Luluam

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.

Screenshot (11)

Luluam avatar Dec 06 '22 00:12 Luluam

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">&times;</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 %}

keybit-1 avatar Apr 26 '23 06:04 keybit-1