jmarantz / soccersub

Game substitution management for soccer coaches
Apache License 2.0
0 stars 0 forks source link

Don't burn down and rebuild DOM on re-sort #9

Open jmarantz opened 7 years ago

jmarantz commented 7 years ago

This is a bit annoying to do, because the event listeners for the nodes currently are registered with an anonymous function binding back to the player. Resetting that listener appears to be impossible in HTML/JS.

The best way to do this appears to be to set up the listener functions based on the index into the sorted players table.

jmarantz commented 7 years ago

Doing this nicely requires an MVC refactor, which is looking useful anyway. E.g. if the model were separate from the UI structures, it could be more easily serialized/deserialized using JSON support.-

It may also be easier to plug in a second storage back-end. Currently it just supports local-storage, which is probably a good default, but it ties the team to a single device.

jmarantz commented 6 years ago

I just thought of a simpler way to do it: bind a player-index into the listener events and use an array of player names. The array of strings can be re-arranged, but the indexes and listeners don't need to change.