문제

I'm trying to do something like this:

http://jsfiddle.net/bATu3/5/

Where the entire view is generated within an object, privately and return via a public method so that it can be generated on the page. I'm doing something wrong and would appreciate any pointers to help me sort this out.

도움이 되었습니까?

해결책

Try this:http://jsfiddle.net/bATu3/10/

Basically there were few errors: Be careful of the use of 'this' within callback functions. Also, note the data bind variables <p><strong data-bind="text:firstName"></strong></p>

다른 팁

another way to do this is: http://jsfiddle.net/bATu3/14/

you can specify the scope for computed values by passing it as a secondary parameter as noted here: Knockout: Computed Observables (read the "Managing ‘this’" section)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top