Changed flat javascript view model to a function closure, so the 'this' variable can be used.
Made the generated viewmodel and web page compatible and working.