Tutorial by Examples

Cusom bindings should be registered by extending the current knockout bindingHandlers object.This is done by adding a new property to the object. ko.bindingHandlers.newBinding = { init: function(element, valueAccessor, allBindings, viewModel, bindingContext) { }, update: function(e...
This example implements a custom binding that toggles visibility (similar to the existing visible binding), but will utilize jQuery's fading API to animate the transition from visible to invisible. Custom binding definition: //Add a custom binding called "fadeVisible" by adding it as a p...
This example is a custom binding that replaces text whenever an input value is updated. In this case, spaces will be replaced with "+". It is intended to be used alongside the existing value binding, and shows binding with an object literal. Sample markup with the replaceText binding: &l...
Custom binding definition function regExReplace(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var observable = valueAccessor(); var textToReplace = allBindingsAccessor().textToReplace || ''; var pattern = allBindingsAccessor().pattern || ''; var flags = all...

Page 1 of 1