morawcik
morawcik

Reputation: 90

Knockout - binding like attribute

It is possible to make binding like

<ul data-foreach="myArray">
    <li data-text='title'></li>
</ul>

or

<ul data-bind-foreach="myArray">
    <li data-bind-text='title'></li>
</ul>

instead of

<ul data-bind="foreach: myArray">
    <li data-bind='text: title'></li>
</ul>

Upvotes: 2

Views: 58

Answers (2)

Jon
Jon

Reputation: 11

Doing what your asking would require a lot of work. Another option could possibly writing a custom binding handler if your looking for specific functionality for something.

<ul data-bind="someBinding: myArray">
    <li data-text='title'></li>
</ul>

http://knockoutjs.com/documentation/custom-bindings.html

Upvotes: 0

Jeroen
Jeroen

Reputation: 63830

You're probably not gonna like my answer... AFAIK: No, with just Knockout this isn't really an option.

The KO 3.0 plugin Knockout.Punches may do similar things, you could have a look at that.

Other than that you'd have to write your own extension to KO.

Upvotes: 1

Related Questions