0

requireJSを使用してロードするバインディングハンドラーのセットがありますが、ハンドラーが追加される前にkoがバインディングしていたことが問題であることが判明しました。これは十分に公平です。

私が抱えている問題は、これが発生したときにエラーが発生しなかったことです。ノックアウトは、登録されていないバインディングハンドラーを無視します。

エラーを強制する方法はありますか、または少なくともconsole.logバインディングハンドラーが見つからない場合はありますか?

例:

<div data-bind="madeUpBinding: {}">No error here...</div>

このhtmlスニペットはknockoutjsによって解析さmadeUpBindingれ、バインディングハンドラーとして登録されていなくても、エラーなどは表示されません。

4

1 に答える 1

1

If you read the docs on custom bindings you can see why it doesn't give an error. You can use other bindings as a way to pass parameters to your custom binding. In the docs they have a slideVisible binder and they use a non-existent slideDuration to pass the duration of the animation.

So how do you tell if madeUpBinding is a non-existent binding, or a placeholder used to pass parameters to some other binding?

于 2013-02-20T01:20:17.613 に答える