bleehu / CXDocs

Compound X rules displayed as web pages. Written in Python, served with Flask and bootstraped with bootswatch.
1 stars 1 forks source link

Flask Flash Messages Only Appear on Reload #264

Open RyuGuardian opened 5 years ago

RyuGuardian commented 5 years ago

The messages put into flask.flash don't appear when updating the UI in real time. The site has to be reloaded.

Examples: Try logging in using bad credentials: the page reloads automatically, therefore you see the flash message. Delete a character: no message appears, but if you refresh or go to the home page, you'll see the message (or messages if you delete multiple characters). (This is easier seen after PR #263 is merged, or you can checkout branch AK/delete-character.)

bleehu commented 5 years ago

I think the answer is to remove flash feedback for user stories that we are converting to asynchronous AJAX calls. Instead we should use jQuery .ajaxSuccess() event handler to trigger simple functions that add the DOM element that we would have added in the case of flash feedback. In related work, I need to remove the 302 redirects on the asynch endpoints so that if they work, they return 200, which is what AJAX is expecting.

https://api.jquery.com/ajaxsuccess/