knockoutjs:Example 1: 基本的な書式:The custom binding
基本的な書式なので動きは無し。
<body>
<div data-bind="yourBindingName: someValue"> </div>
<script type="text/javascript">
ko.bindingHandlers.yourBindingName = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
// This will be called when the binding is first applied to an element
// Set up any initial state, event handlers, etc. here
},
update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
// This will be called once when the binding is first applied to an element,
// and again whenever the associated observable changes value.
// Update the DOM element based on the supplied values here.
}
};
</script>
</body>
Copyright © 2009 by PCスキルの小技・忘却防止メモ. All rights reserved.