Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <textarea class="form-control" placeholder="Comments" rows="10" data-bind="value: $root.GetTabComment($data).Comment, valueUpdate: 'keyup'"></textarea>
- Comment.subscribe(function(){
- //save code
- });
- valueUpdate: 'input'
- <p>Type stuff here:
- <input data-bind='value: instantaneousValue, valueUpdate: "input"' /></p>
- <p>Current throttled value: <b data-bind='text: throttledValue'> </b></p>
- <div data-bind="visible: loggedValues().length > 0">
- <h3>Stuff you have typed:</h3>
- <ul data-bind="foreach: loggedValues">
- <li data-bind="text: $data"></li>
- </ul>
- </div>
- function AppViewModel() {
- this.instantaneousValue = ko.observable();
- this.throttledValue = ko.computed(this.instantaneousValue)
- .extend({ throttle: 400 });
- // Keep a log of the throttled values
- this.loggedValues = ko.observableArray([]);
- this.throttledValue.subscribe(function (val) {
- if (val !== '')
- this.loggedValues.push(val);
- }, this);
- }
- ko.applyBindings(new AppViewModel());
Add Comment
Please, Sign In to add comment