mbest / knockout

My enhancements to Knockout
35 stars 4 forks source link

re-organizing binding parameters #2

Open mbest opened 12 years ago

mbest commented 12 years ago

Each binding has a unique name, such as value and text. Bindings generally take a single parameter; for example: text: 'Hello'.

Some binding (options, foreach, template) often take multiple parameters. Currently there are two methods used to specify multiple parameters. 'options' uses multiple top-level bindings (options: list, optionsText: 'name', optionsValue: 'id'), but only 'options' has a binding handler. 'foreach' and 'template' use a sub-object (template: {name: 'me', data: mydata}), but can also be called with a single parameter (template: 'me').

Another class of bindings (css, style, attr, event) also take multiple parameters, but for a different reason. These current accept an object where the property name is the class, style, etc. to be bound to and the value is the dependency for that binding.

I propose that all independent bindings be specified at the top level. If a binding requires multiple parameters, these will specified using a sub object. In the case of bindings that require two parameters (key and value), we'll use a method of combining the binding type with the key, such as style.color: 'blue'