Set binding options later

17 views
Skip to first unread message

knar...@gmail.com

unread,
Jan 13, 2017, 8:48:51 AM1/13/17
to KnockoutJS
Is it possivle to set options from inside my js script?

For example a div which has a binding I wrote like the following:
<div data-bind="mybinding: {options}"></div>

For a long list of options this method looks really ugly in the html file.

noirabys

unread,
Jan 13, 2017, 9:22:15 AM1/13/17
to KnockoutJS
hi,
you can pass in any model variables
and read them in your binding

if you want dynamic updates of your binding and you pass in observables be sure to access them within the update method because
ko makes a dependency analysis and only calls the update method if a depedency changes. for example one of your observable options

best regards,
 noirabys
Reply all
Reply to author
Forward
0 new messages