mbest / knockout.punches

A collection of enhanced binding syntaxes using Knockout 3+
http://mbest.github.io/knockout.punches/
238 stars 19 forks source link

Filters with custom bindings #59

Closed alexswan10k closed 9 years ago

alexswan10k commented 9 years ago

So I know I can do:

<span data-bind="text: name | fit:20 | uppercase"></span>

but what I really want to do is:

<div data-bind="someCustomBinding: data | transform | transform2:param"></div>

where data is an array of a known thing, or other complex object. It looks like currently the punches syntax is only supported for text and css.

Is this possible?

mbest commented 9 years ago

As described in the documentation, you'd use ko.punches.textFilter.enableForBinding('someCustomBinding') or ko.punches.textFilter.enableForBinding(ko.bindingHandlers.someCustomBinding).

alexswan10k commented 9 years ago

Thanks, I went over this a few times and it didn't occur to me it was what i wanted. Apologies. I think I dismissed it because applying a function off a binding that is totally unrelated to the binding I wished to target seemed counter intuitive.

mbest commented 9 years ago

Are you saying that the documentation is confusing or the API? Can you elaborate?

alexswan10k commented 9 years ago

The API.

I am using ko.bindings.someCustomBinding with the filter ko.punches.someCustomFilter, and it seems a little odd that i would have to go through ko.punches.textFilter (totally unrelated filter) to hook this binding up.

I understand there are perhaps implementation reasons for this, but I guess I would have expected something closer to ko.punches.enableForBinding(binding)?

mbest commented 9 years ago

Thanks for the extra details. I'll see if I can make the documentation more clear.

alexswan10k commented 9 years ago

Much appreciated. Thanks.