2
我有以下基於Ryan Niemeyer的博客的自定義綁定,但我是它不起作用。而不是貶低他,這個div根本不顯示。我嘗試添加「init」函數,但是這並沒有解決問題,所以我回到了像Ryan這樣的簡單更新函數中。Knockout自定義綁定擴展「IF」綁定
ko.bindingHandlers.fadeInIf = {
update: function(element, valueAccessor) {
ko.bindingHandlers.if.update(element, valueAccessor);
$(element).fadeIn();
}
};
在HTML
我做了以下內容:
<div data-bind="fadeInIf: show">...</div>
博客文章:http://www.knockmeout.net/2011/07/another-look-at-custom-bindings-for.html