KnockoutJs Help, can anyone critique my code on this pen? And explain why the description doesn't show when the click event fires?

23 views
Skip to first unread message

Jack Weldon

unread,
Jan 11, 2017, 9:44:23 AM1/11/17
to KnockoutJS

noirabys

unread,
Jan 12, 2017, 3:29:12 AM1/12/17
to KnockoutJS
hi,

1. use click: binding as shortcut to event:click
   default parameter is $data
2. use anonymous function if you need other parameters in the click binding
   code such as: click: callMyMethod(a,b) will call the method directly and not on click!
   click: function(){ callMyMethod($data,whatever); }
3. use method to set values of observables don't overwrite them with = assignment
4. its better to load the data into an array and set that array after created into the observableArray , otherwise each access would render the view again -> potential bad performance

http://codepen.io/anon/pen/vgGJey?editors=1111

best regards,
noirabys

Am Mittwoch, 11. Januar 2017 15:44:23 UTC+1 schrieb Jack Weldon:
http://codepen.io/weldonjack/pen/YNPvqb
Reply all
Reply to author
Forward
0 new messages