You should use canJs.
You should look for fiddles end examples on canjs.com.
Take for example this simple fiddle http://jsfiddle.net/xKc3H/339/ and try to understand how it works.