How to have multiple data-bind attributes on one element? How to have multiple data-bind attributes on one element? javascript javascript

How to have multiple data-bind attributes on one element?


Like this:

<a data-bind="html: name, attr: { href: url }">

You use comma-separated bindings - the attribute is the same as passing an object:

{    html: name,     attr: { href: url }}

Or, if you're asking about multiple attr bindings at once:

<a data-bind="html: name, attr: { href: url, 'data-prop': FullName }">


This is how I implemented the source attribute and click event using data-bind. You may find it useful.

<img data-bind="{click: function(data, event) {ESVendorWidget.loadFunction(data,event)},                 attr: {src: $data.Photo.PhotoUrl }}"     alt="package pic" class="big" />


I simply use:

<input type="checkbox"    data-bind="click: callFunction(), checkedValue: 0, checked: Card.Days">

for a checkbox element.