Knockout BindingHandlers without required values

Is it possible to create a Knockout binding binding that does not have the required values?

ko.bindingHandlers['superAction'] = { init: function(...) { }, update: function(...) { } }; 

For example, the syntax could be:

 <span data-bind="superAction"></span> 

There is an optional value, so sometimes it can be:

 <span data-bind="superAction: myProperty"></span> 

I tried only a colon, without a colon ... They all throw exceptions for parsing at runtime.

+7
source share
2 answers

This is possible from knockout 3.0. See https://github.com/knockout/knockout/issues/289 .

+3
source

No, everything inside the data-bind attribute must be a valid javascript object literal if it is wrapped in curly braces. But { superAction } not.

+3
source

All Articles