mardi 14 juin 2016

knockout.js - data-bind attr default values

I have a simple html element with an attr binding:

<img src="defaultImage.png" alt="default" data-bind="attr: {src: imgUrl, alt: imgAlt}" />

What I'd like to do is have a custom extender to take the default value for src and alt and automatically initialize them into the Knockout observables.

There are plenty of examples for doing this for a value or text binding but none for arbitrary attr bindings.

Is this possible?

Aucun commentaire:

Enregistrer un commentaire