205stelzear / elections

Website / Webapp to create and view elections for any Scout group
https://205stelzear-elections.v-ed.ca/
MIT License
0 stars 0 forks source link

Make the app fully contained, where reloading to reset state isn't necessary #43

Open V-ed opened 5 years ago

V-ed commented 5 years ago

This basically means that the button in the results page to return to the homepage would not reload the page, but rather reset the states of every variable, remove all dynamically added elements, and dump the created data by itself, rather than using the reload page method.

This would allow the app to be fully modular, not requiring any internet connection for ALL interactions if using it through the web-hosted way. The locally downloaded website would still work even if offline, because it would reload the file, and not use any internet.

EDIT : "remove all dynamically added elements" instead of a method for it, this could be done by the setup methods of each "view" - they should therefore know what is dynamically added, as they are the one adding it afterall.

V-ed commented 5 years ago

A problem with this will be how to handle all of the events attached to all sorts of inputs in the different views of this program.

My idea to go over this would be to create an utility method / class that stores all the details of the inputs, event types, and function, which would allow a generic utility method to iteratively remove all events added.

Therefore, every addEventListener that I use in this project will be be changed to support that new method / class, unifying everything nicely.

Quick removeEventListener doc link : https://www.w3schools.com/jsref/met_element_removeeventlistener.asp

Quick link to static method to classes : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static