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

Items do not delete but rather add new items upon refresh

Open maty714 opened this issue 2 years ago • 12 comments

After adding a note and then trying to delete that note, nothing happens. When the page is reloaded manually, a duplicate of the previous note gets added. This occurred right after cloning the repo and running through vs code.

maty714 avatar May 30 '22 05:05 maty714

hey maybe im late but i'll reply anyway... My mistake was that i wrote inClick instead of onClick in "home.html" . There were no other errors for me

BrokenDetector avatar Jun 23 '22 12:06 BrokenDetector

hi, my notes are not getting deleted, i tried copy pasting the original code, still its not working

alien204 avatar Jun 30 '22 18:06 alien204

Are you getting any error or notes just not getting deleted?

BrokenDetector avatar Jun 30 '22 19:06 BrokenDetector

there is no error or any request sent, the button itself is not working

alien204 avatar Jul 01 '22 08:07 alien204

is there any way i can give access to my private repository and you try to run it? I'm new here

BrokenDetector avatar Jul 01 '22 09:07 BrokenDetector

you can give me access as a collaborator, but if u can figure out what is different in yours that would be easier

alien204 avatar Jul 01 '22 09:07 alien204

hey! thanks for that, i got it working somehow, didn't change anything, and i can't figure out what went wrong

alien204 avatar Jul 01 '22 10:07 alien204

Bro I'm having the same error and I need help :(((

Gabrango avatar Dec 04 '22 18:12 Gabrango

Same issue

CODER6GC avatar Feb 05 '23 10:02 CODER6GC

I found the mistake that I made. There was this piece of code in the base.html that I had neglected to write:

{% block javascript %} {% endblock %}

See if you made the same mistake I did.

Nacholibre2000 avatar Jul 20 '23 09:07 Nacholibre2000

Hi. I had the same issue as well. Make sure that the index.js is properly linked with the base.html file. In the video, he has not written the code of index.js in the base.htm which you can see in this repo. Also make sure that the block code looks something like this {% blockinfo %} and not anything else. The spaces are important. Pasting my base.html as that might help. @Gabrango @CODER6GC

{% block javascript %}
<script type="text/javascript">
    function deleteNote(noteId) {
fetch('/delete-node', {
    method: 'POST',
    body: JSON.stringify({ noteId: noteId }),
}).then((_res) => {
    window.location.href = "/";
});

}

{% endblock %}

This has to be at the bottom. Hope this helps!!

DrashtiSanjayShah avatar Aug 04 '23 07:08 DrashtiSanjayShah

The issue I was facing was in the base.html file, I did not write the code linking the JS code in this file

{% block javascript %}

{% endblock %}

Write this code in the end and hopefully it works for you as well

ChiragBhatiaaa avatar Feb 26 '24 04:02 ChiragBhatiaaa