Hmm... It's a bit more work but this might be cleaner as a Knockout View Model with bindings...