Skip to content Skip to sidebar Skip to footer

How To Have Multiple Data-bind Attributes On One Element?

I need to have multiple data bindings on one element. For example, I want a href as well as a html data-binding on one a tag. I have tried this,

Solution 1:

Solution 2:

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" />

Solution 3:

I simply use:

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

for a checkbox element.

Solution 4:

you can use multiple properties using , like below

<adata-bind="attr: { href:url, id:id , class:classvalue}">

object like this

{ url: 'http://stackoverflow.com', id:'newid' , classvalue: 'classname' }

Solution 5:

you can use like below

data-bind="text: method.method_title, attr: {'id': 'label_method_' + method.method_code}"

Post a Comment for "How To Have Multiple Data-bind Attributes On One Element?"