Guest User

Untitled

a guest
Nov 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <textarea class="form-control" placeholder="Comments" rows="10" data-bind="value: $root.GetTabComment($data).Comment, valueUpdate: 'keyup'"></textarea>
  2.  
  3. Comment.subscribe(function(){
  4. //save code
  5. });
  6.  
  7. valueUpdate: 'input'
  8.  
  9. <p>Type stuff here:
  10. <input data-bind='value: instantaneousValue, valueUpdate: "input"' /></p>
  11.  
  12. <p>Current throttled value: <b data-bind='text: throttledValue'> </b></p>
  13.  
  14. <div data-bind="visible: loggedValues().length > 0">
  15. <h3>Stuff you have typed:</h3>
  16. <ul data-bind="foreach: loggedValues">
  17. <li data-bind="text: $data"></li>
  18. </ul>
  19. </div>
  20.  
  21. function AppViewModel() {
  22. this.instantaneousValue = ko.observable();
  23. this.throttledValue = ko.computed(this.instantaneousValue)
  24. .extend({ throttle: 400 });
  25.  
  26. // Keep a log of the throttled values
  27. this.loggedValues = ko.observableArray([]);
  28. this.throttledValue.subscribe(function (val) {
  29. if (val !== '')
  30. this.loggedValues.push(val);
  31. }, this);
  32. }
  33.  
  34. ko.applyBindings(new AppViewModel());
Add Comment
Please, Sign In to add comment